data raschdata; input ID $ 1-10 Q01 11 Q02 12 Q03 13 Q04 14 Q05 15 Q06 16 Q07 17 Q08 18 Q09 19 Q10 20 Q11 21 Q12 22 Q13 23 Q14 24 Q15 25 Q16 26 Q17 27 Q18 28; cards ; Richard M 111111100000000000 Tracie F 111111111100000000 Walter M 111111111001000000 Blaise M 111100101000000000 Ron M 111111111100000000 William M 111111111100000000 Susan F 111111111111101000 Linda F 111111111100000000 Kim F 111111111100000000 Carol F 111111111110000000 Pete M 111011111000000000 Brenda F 111110101100000000 Mike M 111110011111000000 Zula F 111111111110000000 Frank M 111111111111100000 Dorothy F 111111111010000000 Rod M 111101111100000000 Britton F 111111111100100000 Janet F 111111111000000000 David M 111111111100100000 Thomas M 111111111110100000 Betty F 111111111111000000 Bert M 111111111100110000 Rick M 111111111110100110 Don M 111011000000000000 Barbara F 111111111100000000 Adam M 111111100000000000 Audrey F 111111111010000000 Anne F 111111001110010000 Lisa F 111111111000000000 James M 111111111100000000 Joe M 111111111110000000 Martha F 111100100100000000 Elsie F 111111111101010000 Helen F 111000000000000000 ; run; /*writing a macro statement to a temp folder*/ ods listing close; proc contents data=raschdata; ods output variables=kaz; run; ods listing; data kaz2; set kaz; if type="Num"; first='%ue (var1='; last=");"; sassyntax=first||variable||last; run; data _null_;set kaz2; file "c:\temp\temp.txt"; put sassyntax 1-50 ; run; /*In case a data set result exists already in a working folder, I want to delete it, so it doesn't intervene the append process*/ proc datasets library=work; delete RESULT; run; %macro ue (var1=); proc transpose data=raschdata out=raschdata2; id ID; var &var1; run; proc transpose data=raschdata2 out=raschdata3; run; data raschdata4; set raschdata3; Item=" "; Item="&var1 "; response=&var1; drop &var1; run; proc append base=result force data=raschdata4; run; %mend ue; /*reading a macro statement from a temp folder*/ %include "c:\temp\temp.txt"; /*creating extreme observation indicators*/ /*they must be removed from analytical sample*/ proc sql;create table result2 as select *, mean(response) as itemmeanresponse from result group by item; run; proc sql;create table result3 as select *, mean(response) as personmeanresponse from result2 group by _name_; run; data result4; set result3; analyzable=1; if itemmeanresponse = 0 or itemmeanresponse = 1 or personmeanresponse = 1 or personmeanresponse = 0 then analyzable=0; run; /*Rasch model*/ proc logistic data=result4 descending; where analyzable=1; class item _name_; model response = item _name_; ods output ParameterEstimates=RaschResult; run; /*Reporting results*/ proc print data=RaschResult noobs; title "Item Easiness (Flip signs (+ -), so they are item difficulty)"; where variable="Intercept" or variable="Item"; run; proc print data=RaschResult noobs; title "Person Measures"; where variable="Intercept" or variable="_NAME_"; run;