Hi Scott;
This is the part of log that relates to the code:
Thank you
LOG:
NewParmAdd=L3_0+L3_13+L3_14 Main=L3_13 L3_14 OrderMain= Order12way= Order22way= Order13way=
Order23way= Order33way= OrderMainMax= Order12wayMax= Order22wayMax= Order13wayMax=
Order23wayMax= Order33wayMax= class=16 item=3 scorepattern=30011 thresh=4 attpattern=0011
classatt1=1 classatt2=1 classatt3=1 classatt4=1 itematt1=0 itematt2=0 itematt3=1 itematt4=1
scoreatt1=0 scoreatt2=0 scoreatt3=1 scoreatt4=1 BeginS=. G_11=G_11 G_12=G_12 G_13=G_13 G_14=G_14
EndS=. LongSParm=19 BeginI=. LInt=L3_0 L1_11= L2_11= L3_11= L4_11= L5_11= L6_11= L7_11=
L8_11= L9_11= L10_11= L11_11= L12_11= L13_11= L14_11= L15_11= L1_12= L2_12= L3_12=
L4_12= L5_12= L6_12= L7_12= L8_12= L9_12= L10_12= L11_12= L12_12= L13_12= L14_12=
L15_12= L1_13= L2_13= L3_13=L3_13 L4_13= L5_13= L6_13= L7_13= L8_13= L9_13= L10_13=
L11_13= L12_13= L13_13= L14_13= L15_13= L1_14= L2_14= L3_14=L3_14 L4_14= L5_14= L6_14=
L7_14= L8_14= L9_14= L10_14= L11_14= L12_14= L13_14= L14_14= L15_14= LastI=.
LongIParm=16 LongOrderMain=. _ERROR_=0 _N_=33
This is the code:
%MACRO Equations (structorder, maxitemorder);
%let num_skills=4;
%let numatt=4;
%let numitem=%eval(2**&num_skills-1);
%let numclass=%eval(2**&num_skills);
%let IDname=num_student;
%let numatt=&num_skills; /*change it to what ever value for skill*/
DATA kernel;
/* Listing all character variables eventually created*/
LENGTH NewStruc NewStrucAdd NewParm NewParmAdd
Main OrderMain Order12way Order22way
Order13way Order23way Order33way
OrderMainMax Order12wayMax Order22wayMax
Order13wayMax Order23wayMax Order33wayMax $500;
SET kernel;
/*** STRUCTURAL MODEL PARAMETERS*/
/* Dummy variable to use as placeholder*/
BeginS = .;
/* Main effects*/
%DO a=1 %TO &numatt.;
IF classatt&a.=1 THEN G_1&a.= "G_1&a. ";
ELSE G_1&a. = G_1&a.;
%END;
* Last variable to use as dummy place;
EndS = .;
* Creating string variables to use in NEW equations;
CALL CATX(" ", NewStruc, OF BeginS--EndS);
NewStruc = TRANWRD(NewStruc, "." , " " );
NewStruc = STRIP(NewStruc);
NewStrucAdd = TRANWRD(STRIP(NewStruc), " " , "+" );
* Creating index for longest possible number of structural parms;
LongSParm = LENGTH(STRIP(NewStruc));
run;
* Saving longest parm as new variable for class reference statement;
PROC SORT DATA=kernel; BY item DESCENDING LongSParm; RUN;
DATA SaveSLong; SET kernel; BY item;
IF FIRST.item THEN NewStrucMax=STRIP(NewStruc); ELSE DELETE; RUN;
* Merge longest parm back into data;
DATA kernel; LENGTH NewStrucMax NewStrucMaxAdd $200; MERGE SaveSLong kernel; BY item;
NewStrucMaxAdd = TRANWRD(STRIP(NewStrucMax), " " , "+" ); RUN;
* Clearing extra datasets;
PROC DATASETS LIB=WORK NOLIST; DELETE SaveSLong; RUN; QUIT;
PROC SORT DATA=kernel; BY item thresh; RUN;
* Re-opening data;
DATA kernel; SET kernel;
*** ITEM PARAMETERS;
* Dummy variable to use as placeholder;
BeginI=.;
* Intercepts per item (1);
%DO i=1 %TO &numitem.;
IF item=&i. THEN LInt = "L&i._0 ";
ELSE LInt = LInt;
%END;
* Main effects per item (up to # attributes);
%DO Num1=1 %TO &numatt.;
%DO i=1 %TO &numitem.;
IF item=&i. AND scoreatt&Num1.=1 THEN L&i._1&Num1. = "L&i._1&Num1. ";
ELSE L&i._1&Num1. = L&i._1&Num1.;
%END;
%END;
/* Last variable to use as dummy place to end series*/
LastI = .;
/* Creating string variables to use in NEW equations*/
CALL CATX(" ", NewParm, OF BeginI--LastI);
NewParm = TRANWRD(NewParm, "." , " " );
NewParm = STRIP(NewParm);
NewParmAdd = TRANWRD(STRIP(NewParm), " " , "+" );
* Creating index for longest possible number of parms;
LongIParm = LENGTH(STRIP(NewParm));
RUN;
* Saving longest parm as new variable for NEW statement;
PROC SORT DATA=kernel; BY item DESCENDING LongIParm; RUN;
DATA SaveILong; SET kernel; BY item;
IF FIRST.item THEN NewParmMax=NewParm; ELSE DELETE; RUN;
* Merge longest parm back into data;
DATA kernel; LENGTH NewParmMax $100; MERGE SaveILong kernel; BY item; RUN;
* Clearing extra datasets;
PROC DATASETS LIB=WORK NOLIST; DELETE SaveILong; RUN; QUIT;
* Creating string variables for ordering constraints;
%LET numatt1 = %EVAL(&numatt.-1);
%LET numatt2 = %EVAL(&numatt.-2);
DATA kernel; SET kernel;
* Main effects;
CALL CATX(" ", Main, OF L1_11--L&numitem._1&numatt.);
PUTLOG _ALL_;