/*Oct 2002*/ /*Based on comments at the ASA meeting, I am examining item level more closeyl by doing factor analysis*/ /*specifying library*/ %let direc=C:\AAA PROJECTS\ECBW\N2P\; %let WD=C:\AAA PROJECTS\ECBW\N2P\; libname here "&direc" ; libname here "&WD" ; libname there "&direc.data4" ;/*data storage*/ data base;set here.all; keep STDID SEX /*F1s12A F1s12B F1s12C F1s12D F1s12E F1s12F F1s12G F1s12H F1s12I F1s12J F1s12K F1s12L F1s12M F1s12N F1s12O F1s12P F1s12Q F1s12R */ /*the values of these are already reverse coded in nelsrunprog4.5sas*/ late cut skip cheat copy fight gang racist sexist steal destroy smoke drink drug weapon abuse talkback disobey F_abuse F_destroy F_fight F_copy ; /*these are already reverse conded in nelsrunprogrog4.5.sas*/ late=F1S12A; cut=F1S12B; skip=F1S12C; cheat=F1S12D; copy=F1S12E; fight=F1S12F; gang=F1S12G; racist=F1S12H; sexist=F1S12I; steal=F1S12J; destroy=F1S12K; smoke=F1S12L; drink=F1S12M; drug=F1S12N; weapon=F1S12O; abuse=F1S12P; talkback=F1S12Q; disobey=F1S12R; /*these are items that behave differently across gender*/ /* if sex=2 then do; F_abuse=abuse; abuse=.; F_destroy=destroy; destroy=.; F_fight=fight; fight=.; F_copy=copy; copy=.; end; */ run; proc sort;by sex;run; /*Here to create an excel table deviance_frequency_table.xls*/ /*Here to create an excel table deviance_frequency_table.xls*/ /*Here to create an excel table deviance_frequency_table.xls*/ *****************************************************************************; *****************************************************************************; *****************************************************************************; *****************************************************************************; proc freq; by sex; tables late cut skip cheat copy fight gang racist sexist steal destroy smoke drink drug weapon abuse talkback disobey /*F_abuse F_destroy F_fight F_copy*/; ods output OneWayFreqs=freqresult; run; data freqresult2;set freqresult; jun=_n_; new=table||sex; run; proc sort;by new;run; data freqresult3;set freqresult2; by new; if first.new then count=0; count+1; if count=3 then code="Sometimes"; if count=4 then code="Often"; if count=2 then code="Rarely"; if count=1 then code="Never"; run; proc sort;by jun;run; data boy;set freqresult3; keep table code Malefreqency Malepercent; if sex=1; Malecode=code; Malefreqency= Frequency; Malepercent=percent/100; run; data girl;set freqresult3; keep table Femalefreqency Femalepercent; if sex=2; Femalecode=code; Femalefreqency= Frequency; Femalepercent=percent/100; run; data bothsex;merge boy girl; length desc $ 40; if table="late" then desc="To be late for school"; if table="copy" then desc="To copy someone's homework"; if table="talkback " then desc="To talk back to teachers"; if table="disobey " then desc="To disobey school rules"; if table="skip" then desc="To skip school a whole day"; if table="cut" then desc="To cut a couple of classes "; if table="fight" then desc="To get into physical fights"; if table="cheat" then desc="To cheat on tests"; if table="sexist" then desc="To make sexist remarks"; if table="smoke" then desc="To smoke on school grounds"; if table="racist" then desc="To make, racist remarks"; if table="gang" then desc="To belong to gangs"; if table="weapon" then desc="To bring weapons to school"; if table="destroy" then desc="To destroy, school property"; if table="drink" then desc="To drink alcohol at school"; if table="steal" then desc="To steal belongings frm school"; if table="abuse" then desc="To abuse teachers"; if table="drug" then desc="To use drugs at school"; run; proc export data=bothsex outfile="C:\My Documents\AERA\deviance_frequency_table.xls" dbms=excel2000 replace;run; *****************************************************************************; *****************************************************************************; *****************************************************************************; *****************************************************************************; option noxwait xsync; %let win= C:\WINSTEPS\winsteps; %let WD=&direc; %let scale=F1dev; %let ni =22;/*n of items*/ %let codes=1234; data F1dev;set base; /*women have DIF for these items, so treat them separately*/ /* if sex=2 then do; F_abuse=abuse; abuse=.; F_destroy=destroy; destroy=.; F_fight=fight; fight=.; F_copy=copy; copy=.; end; */ blank=' '; file "&WD.F1dev.dat"; put (STDID) (5.0) (blank)(1.0) (sex) (1.0) ( late cut skip cheat copy fight gang racist sexist steal destroy smoke drink drug weapon abuse talkback disobey /*F_abuse F_destroy F_fight F_copy*/ )(1.0); run; /* late cut skip cheat copy fight gang racist sexist steal destroy smoke drink drug weapon abuse talkback disobey */ /*these are lables for variables, which will come, in the WINSTEP control file, in between END and END NAMES*/ filename new "C:\WINSTEPS\F1dev.con"; data _null_; file new; put '&inst '; put " item1=8"; put " name1=1"; put " ni=&ni"; put " HLINES=n"; put " ;target=y"; put ";table="; put " person=student"; put " item=question"; put " codes=&codes"; put " udecim=6"; put "; pfile=F1dev.pfile"; put "; ifile=F1dev.ifile"; put " csv=n"; put " data=&WD.F1dev.dat"; put ' &end'; put "late"; put "cut"; put "skip"; put "cheat"; put "copy"; put "fight"; put "gang"; put "racist"; put "sexist"; put "steal"; put "destroy"; put "smoke"; put "drink"; put "drug"; put "weapon"; put "abuse"; put "talkback"; put "disobey"; put "F_abuse"; put "F_destroy"; put "F_fight"; put "F_copy"; put " END NAMES"; run; filename idfile "C:\WINSTEPS\idfile2.txt"; data _null_; file idfile; put "12"; put "7"; put "14"; put "16"; put "13"; put "10"; put "11";/*up to here May 2003*/ put "15"; put "8"; put "9"; run; x "start &win F1dev.con F1dev_whole.out ifile=F1dev_whole.ifile pfile=F1dev_whole.pfile "; x "start &win &WDF1dev.con F1dev._whole.out ifile=F1dev._whole.ifile pfile=F1dev._whole.pfile "; x "start &win &WDF1dev.con F1dev._boys.out pselect=??????1* ifile=F1dev._boys.ifile pfile=F1dev._boys.pfile"; x "start &win &WDF1dev.con F1dev._boys.out pselect=??????1* ifile=F1dev._boys.ifile idfile=idfile.txt pfile=F1dev._boys2.pfile"; /*without mistfit May 2003*/ x "start &win &WDF1dev.con F1dev._boys.out pselect=??????1* ifile=F1dev._boys.ifile idfile=idfile2.txt pfile=F1dev._boys3.pfile"; x "start &win &WDF1dev.con F1dev._girls.out pselect=??????2* ifile=F1dev._girls.ifile pfile=F1dev._girls.pfile"; *x "start &win &WDF1dev.con F1dev._09.out pselect=???????????????????????9* ifile=F1dev._09.ifile"; *x "start &win &WDF1dev.con F1dev._10.out pselect=??????????????????????10* ifile=F1dev._10.ifile"; *x "start &win &WDF1dev.con F1dev._11.out pselect=??????????????????????11* ifile=F1dev._11.ifile"; *x "start &win &WDF1dev.con F1dev._12.out pselect=??????????????????????12* ifile=F1dev._12.ifile"; /*CHECKING DIF*/ data blank; set _null_; ENTRY=.; MEASURE=. ; STTS=.; COUNT=.; SCORE=.; STDER=.; INMSQ=.; INZSTD=.; OUTMS =.; OUTZSTD=.; DISPL =.; CORR =.; WEIGHT=.; G =.; M =" "; NAME=" "; MFIT =.; subgroup=" "; %macro edward (suji); FILENAME raw2 "&WDF1dev._&suji..ifile"; data outdata; infile raw2 missover; input ENTRY MEASURE STTS COUNT SCORE STDER INMSQ INZSTD OUTMS OUTZSTD DISPL CORR WEIGHT G M $ NAME $; if stTS < = -2 then measure=.; MFIT=0; if OUTMS > 2 then MFIT=1; if entry > -999; subgroup="&suji"; proc sort; by name; run; proc append base=blank data=outdata; run; %mend edward; %edward (suji=whole); %edward (suji=boys); %edward (suji=girls); *%edward (suji=09); *%edward (suji=10); *%edward (suji=11); *%edward (suji=12); *%macro dummy; data here.F1dev._idif; set blank; run; proc sort;by subgroup;run; ods html file="&WDF1dev.body.htm" contents="&WDF1dev.contents.htm" page="&WDF1dev.page.htm" frame="&WDF1dev.index.htm"; filename outfiles "&WD"; goptions gsfname=outfiles dev=gif gunit=pct cback=white htitle=6 htext=3 ftext=swissb ctext=black vsize=8 hsize=8; title1 font=duplex "Item difficulty varying across grades"; footnote1 ""; symbol interpol=spline /*join*/ value=dot height=1; proc gplot data=here.F1dev._idif; plot measure*subgroup=name / /*overlay*/; run; quit; ods html close; proc print data=here.F1dev._idif;run; *%mend dummy; /*Person measures*/ /*Person measures*/ /*Person measures*/ /*Person measures*/ /*Person measures*/ *%macro ken (scale=); *%let scale=whole; /*whole*/ FILENAME raw1 "&direc.F1dev._whole.pfile"; data F1dev;infile raw1 missover; *length TchID $ 8; input ENTRY measure STTS COUNT SCORE STDER INMSQ INZSTD OUTMS OUTZSTD DISPL CORR WEIGHT STDID ; if stTS < = -2 then measure=.; MFIT=0; if OUTMS > 2 then MFIT=1; if entry > -999; F1dev.R=measure; F1dev.ERR=STDER; F1dev.MFIT=MFIT; F1dev.RLOG=log(measure+ 10); run; proc sort;by STDID;run; /*boys*/ FILENAME raw1 "&direc.F1dev._boys2.pfile"; data BF1dev;infile raw1 missover; *length TchID $ 8; input BENTRY Bmeasure BSTTS BCOUNT BSCORE BSTDER BINMSQ BINZSTD BOUTMS BOUTZSTD BDISPL BCORR BWEIGHT STDID ; if BstTS < = -2 then Bmeasure=.; BMFIT=0; if BOUTMS > 2 then BMFIT=1; if Bentry > -999; BF1dev.R=Bmeasure; BF1dev.ERR=BSTDER; BF1dev.MFIT=BMFIT; BF1dev.RLOG=log(Bmeasure+ 10); run; proc sort;by STDID;run; /*boys*/ /*I further reduced the number of items following Nick's advice*/ FILENAME raw1 "&direc.F1dev._boys3.pfile"; data CF1dev;infile raw1 missover; *length TchID $ 8; input CENTRY Cmeasure CSTTS CCOUNT CSCORE CSTDER CINMSQ CINZSTD COUTMS COUTZSTD CDISPL CCORR CWEIGHT STDID ; if CstTS < = -2 then Cmeasure=.; CMFIT=0; if COUTMS > 2 then CMFIT=1; if Centry > -999; CF1dev.R=Cmeasure; CF1dev.ERR=CSTDER; CF1dev.MFIT=CMFIT; CF1dev.RLOG=log(Cmeasure+ 10); run; proc sort;by STDID;run; data bothscales; merge F1dev BF1dev CF1dev; by STDID; run; proc univariate data=bothscales plot; var F1devR F1devRLOG BF1devR BF1devRLOG CF1devR CF1devRLOG; run; proc standard data=bothscales out=bothscales mean=0 std=1; var F1devR F1devRLOG BF1devR BF1devRLOG CF1devR CF1devRLOG ; run; data here.F1dev;set bothscales; keep STDID F1devR F1devRlog BF1devR BF1devRlog BMFIT MFIT CF1devR CF1devRlog CMFIT; *if F1devR > 2.5 then F1devR=2.5; *if F1devR < -2.5 then F1devR=-2.5; *if F1devRLOG > 2.5 then F1devRLOG=2.5; *if F1devRLOG < -2.5 then F1devRLOG=-2.5; proc univariate data=here.F1dev plot; var F1devR F1devRLOG BF1devR BF1devRLOG CF1devR CF1devRLOG; run; proc corr data=here.F1dev; var F1devR BF1devR CF1devR;run; proc freq data=here.F1dev; where MFIT > -999; tables BMFIT MFIT CMFIT; run; proc univariate data=here.F1dev plot; class BMfit; var BF1devRlog CF1devRlog ;run;