Help using Base SAS procedures

ERROR : WARNING: Apparent symbolic reference NUM_ not resolved.

Reply
Regular Contributor
Posts: 161

ERROR : WARNING: Apparent symbolic reference NUM_ not resolved.

Hi,

I am trying to simulate binary data and keep getting this error. The problem is that question is only 1 variable.

Thanks

WARNING: Apparent symbolic reference NUM_ not resolved.
ERROR: Missing numeric suffix on a numbered variable list (question1-question).

My codes:
%macro simulation;

%let num_students=100;
%let num_skills=5;
%let num_item=%eval(2**&num_skills-1);
%let num_total=%eval(2**&num_skills);
%let num_reps=1;
%do seed=1 %to &num_reps;

%let mu1=-2.35;
%let mu2=-2.35;
%let mu3=-2.35;
%let mu4=-2.35;
%let mu5=-2.35;
%let mu6=-2.35;
%let mu7=-2.35;
%let mu8=2.35;
%let mu9=-2.35;
%let mu10=-2.35;
%let mu11=-2.35;
%let mu12=-2.35;
%let mu13=-2.35;
%let mu14=-2.35;
%let mu15=-2.35;
%let mu16=2.35;
%let mu17=2.35;
%let mu18=-2.35;
%let mu19=-2.35;
%let mu20=-2.35;
%let mu21=-2.35;
%let mu22=-2.35;
%let mu23=-2.35;
%let mu24=2.35;
%let mu25=2.35;
%let mu26=-2.35;
%let mu27=-2.35;
%let mu28=-2.35;
%let mu29=-2.35;
%let mu30=-2.35;
%let mu31=-2.35;
%let mu32=0;

%let datafile=dat&seed.;
%let commandfile=CDM_&seed.;
%let outputfile=OUT_&seed.;

/*Skills=5 --> need 2**5=32 mu's, which needs to be added*/

/* ADDEDED:to create C directory(IN SAS_CDM) TO SAVE Q-Matrix file*/
LIBNAME sas_cdm "C:\SAS_CDM ";
RUN;
LIBNAME cdm "C:\CDM ";
RUN;

data nu1;
array nu_num{&num_total} nu_num1-nu_num&num_total;
array nu{&num_total} nu1-nu&num_total;
%do i=1 %to &num_total;
nu_num{&i}=exp(&μ&i);
%end;
nu_denom=sum(of nu_num1-nu_num&num_total);
%do j=1 %to &num_total;
nu{&j}=nu_num{&j}/nu_denom;
%end;
drop nu_denom nu_num1-nu_num&num_total;
run;

proc transpose data=nu1 out=nu2; run;

data nu;
set nu2(rename=(col1=nu));
combination=_n_;
drop _name_;
run;

data all_skills;
array skills{&num_skills} skills1-skills&num_skills;
do j=1 to 2;
do i=1 to &num_skills;
if j=1 then skills{i}=1;
else skills{i}=0;
if skills{j}=. then skills{j}=0;
end;
output;
end;
drop i j;
run;

proc means data=all_skills completetypes;
class skills1-skills&num_skills;
output out=all_skills1;
run;

data all_skills2;
set all_skills1;
array lambda1{&num_skills} lambda1_1-lambda1_&num_skills;
array skills{&num_skills} skills1-skills&num_skills;
num=%eval(&num_skills);
if _type_=(2**num)-1 and sum(of skills1-skills&num_skills) ne 0;

/*Lambda Intercept*/
lambda0=-(1.5**sum(of skills1-skills&num_skills));

/*Lambda Main Effect*/
do i=1 to &num_skills;
lambda1{i}=skills{i}*2;
end;

drop num _type_ _freq_;
run;

data all_skills3;
set all_skills2;
question=_n_;
run;

data all_skills4;
set all_skills3;
do combinations=1 to &num_total;
output;
end;
run;

data combinations1;
array attributes{&num_skills} attributes1-attributes&num_skills;
array skills{&num_skills} skills1-skills&num_skills;
set all_skills1(keep=skills1-skills&num_skills _type_);
num=%eval(&num_skills);
if _type_=(2**num)-1;
do i=1 to &num_skills;
attributes{i}=skills{i};
end;
drop skills1-skills&num_skills i _type_ num;
run;

/*ADDED To have a Q-Matrix file in a permenant folder*/
data sas_cdm.combinations;
set combinations1;
combinations=_n_;
run;

/*ADDED: TO chaning the format of combination to ASCII file*/
data _NULL_;
set sas_cdm.combinations;
file "C:\SAS_CDM\class..dat";
put attributes1 attributes2 attributes3 attributes4 attributes5 attributes6 attributes7 combinqtions;
run;

proc sort data=sas_cdm.combinations; by combinations; run;
proc sort data=all_skills4; by combinations; run;

data all_data;
merge all_skills4 sas_cdm.combinations; /*cdm*/
array lambda1{&num_skills} lambda1_1-lambda1_&num_skills;
array sum_lam{&num_skills} sum_lam1-sum_lam&num_skills;
array skills{&num_skills} skills1-skills&num_skills;
array attributes{&num_skills} attributes1-attributes&num_skills;
by combinations;
do i=1 to &num_skills;
sum_lam{i}=lambda1{i}* attributes{i}*skills{i};
end;

logit=lambda0+sum(of sum_lam1-sum_lam&num_skills);
pi_ic=exp(logit)/(1+exp(logit));

run;

data simulated_students;
array nu_skill{&num_total} nu1-nu&num_total;
array cum_skill{&num_total} cum1-cum&num_total;
set nu1;
/*Find Cumulative Distribution*/
cum_skill{1}=nu_skill{1};
do i=2 to &num_total;
cum_skill{i}=cum_skill{i-1}+nu_skill{i};
end;
/*Simulate Students*/
do student_num=1 to &num_students;
rand_uni=ranuni(&seed);
combinations=1;
do j=1 to &num_item;
if cum_skill{j} end;
do question=1 to &num_item;
output;
end;
end;
run;

proc sort data=simulated_students; by combinations question; run;
proc sort data=all_data; by combinations question; run;

data simulated_data;
merge simulated_students(keep=student_num combinations question in=main) all_data(keep=question combinations attributes1-attributes&num_skills skills1-skills&num_skills pi_ic);
by combinations question;
if main;
x_ic=ranbin(&seed,1,pi_ic);
run;

/*simulated Qmatrix*/
data Q_matrix;
set simulated_data;
drop=student_num combinations attributes1-attributes_num_skills po_ic x_ic ;
run;
/* ADDED: To change the format of Q-Matrix to ascii file*/
data _NULL_;
set Q_Matrix;
file "C:\sas_CDM\Q_Matrix.dat";
put question skills1-skills&num_skills;
run;

/* ADDEDED THIS:to change the name to Class*/

data Class_membership;
set nu;
rename combination=Class;
RUN;

/* ADDED: To change the format of Class_membership to ascii file*/

data _NULL_;
set Class_membership;
file "C:\sas_CDM\Class_membership..dat";
put nu class;
run;

/*continue coding*/
proc sort data=simulated_data; by student_num combinations;run;

proc transpose data=simulated_data(keep=student_num combinations question x_ic) out=sas_cdm.student&seed(drop=_name_) prefix=question;
id question;
by student_num combinations;
run;

/*ADDED: To change the format of SAS to ASCII file*/
/* ADDED: To Create all Data Files*/

data _NULL_;
set sas_cdm.student&seed;
file "C:\CDM\student&seed..dat";
put student_num Combinations question1-question&num_ ;
run;

data _NULL_;
set sas_cdm.student&seed;
file "C:\CDM\&datafile..dat";
put student_num Combinations question1-question&num_item;
run;


%end;
%mend;
%simulation;
Regular Contributor
Posts: 161

Re: ERROR : WARNING: Apparent symbolic reference NUM_ not resolved.

please ignore I found out what the problem was
Thanks
Ask a Question
Discussion stats
  • 1 reply
  • 150 views
  • 0 likes
  • 1 in conversation