libname sasin 'h:\EXA\exa8\unscored'; libname sasout 'h:\EXA\exa8\scored'; data dc8ag1; set sasin.dc8ag1; data nc8ag1; set sasin.nc8ag1; data pc8ag1; set sasin.pc8ag1; data sc8ag1; set sasin.sc8ag1; data comb; set dc8ag1 nc8ag1 pc8ag1 sc8ag1; proc sort; by site cohort tcid; libname allkey 'h:\allkey'; data allkey1; set allkey.allkey1; proc sort; by site cohort tcid; data merged; merge comb allkey1; by site cohort tcid; data c8ag1; set merged; run; **Enter year of data collection**; %let yr = 8; data scoredEXA&yr.; set c8ag1; if C&yr.AG19=4 then C&yr.AG19r=1; if C&yr.AG19=3 then C&yr.AG19r=2; if C&yr.AG19=2 then C&yr.AG19r=3; if C&yr.AG19=1 then C&yr.AG19r=4; %let INDATA = scoredEXA&yr.; ** The macro "linmean" creates derived variables which are means of input ** ** scale items. In the case of missisng input items, the output variable ** ** is defined to be missing if half or more of the input items are ** ** missing. Otherwise, missing input items are replaced with the mean of ** ** the nonmissing items. The macro call to linmean specifies the input ** ** items as a string "var_list" of variable names, and specifies the ** ** label and name of the output variable as "var_name" and "var_labl" ** ** respectively. **; %macro linmean; data &INDATA; set &INDATA; label &var_name="&var_labl"; array sumvars {*} &var_list; if n(of sumvars(*))>=.5*dim(sumvars) then &var_name=mean(of sumvars(*)); proc sort; by site tcid; run; %mend linmean; **Compute Current Importance scale**; %let var_name=EXA&yr.CUR; %let var_labl=%str(Current Importance); %let var_list=%str(C&yr.AG1 C&yr.AG2 C&yr.AG3 C&yr.AG4 C&yr.AG5 C&yr.AG6); %linmean; **Compute Future Expectations scales**; **Future Expectations I**; %let var_name=EXA&yr.FUT1; %let var_labl=%str(Future Expectations I); %let var_list=%str(C&yr.AG9 C&yr.AG11 C&yr.AG12 C&yr.AG13 C&yr.AG14 C&yr.AG18); %linmean; **Future Expectations II**; %let var_name=EXA&yr.FUT2; %let var_labl=%str(Future Expectations II); %let var_list=%str(C&yr.AG9 C&yr.AG10 C&yr.AG11 C&yr.AG12 C&yr.AG13 C&yr.AG14 C&yr.AG15 C&yr.AG16 C&yr.AG17 C&yr.AG18 C&yr.AG19r C&yr.AG20 C&yr.AG22); %linmean; data sasout.scoredEXA&yr.; set scoredEXA&yr.; keep site tcid cohort C&yr.AG1 C&yr.AG2 C&yr.AG3 C&yr.AG4 C&yr.AG5 C&yr.AG6 C&yr.AG7 C&yr.AG8 C&yr.AG9 C&yr.AG10 C&yr.AG11 C&yr.AG12 C&yr.AG13 C&yr.AG14 C&yr.AG15 C&yr.AG16 C&yr.AG17 C&yr.AG18 C&yr.AG19 C&yr.AG19r C&yr.AG20 C&yr.AG21 C&yr.AG22 EXA&yr.CUR EXA&yr.FUT1 EXA&yr.FUT2 treatmnt norm; label C&yr.AG19r = "Trouble with the Police - Reversed"; label EXA&yr.CUR = "Current Importance"; label EXA&yr.FUT1 = "Future Expectations I"; label EXA&yr.FUT2 = "Future Expectations II"; run; proc contents; run; proc freq; tables (c&yr.ag19 c&yr.ag19r); run; proc freq; tables (EXA&yr.CUR EXA&yr.FUT1 EXA&yr.FUT2); run;