BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
393310
Obsidian | Level 7

Hi Everyone! I am having some difficulty with creating a functioning do loop to run proc glimmix with multiple dependent and independent variables. I have 9 dependent variables that I want to run 1 by 1 in proc glimmix against all of my predictor variables. I tried following these instructions An easy way to run thousands of regressions in SAS - The DO Loop, however, it only works for my predictor variables. For my dependent variable it will only run the very first outcome which is trouble sleeping. Am I do something wrong, or is it just not possible to have SAS run multiple glimmix functions with different dependent variables? 

 

I appreciate any help!!

data perm.temp; 
 set perm.mentalhealth; 
 array var_list[9] trouble_sleeping hurting_yourself interest depressed little_energy appetite feeling_bad concentrating
 moving_slowly;
 array categorical[22]  gender age scalp_lesions postauricular erythema eyelid_involvement cheilitis flexural_erythema xerosis neck_folds nipple_eczema
keratosis palmar hand_eczema ichthyosis foot_eczema race education_final insurance alopecia pityriasis pain;
array npredictors[9] SCORAD EASI BSA ADSI POEM_SCORE dlqi_score FIVED_SCORE RL_SCORE flare;
  do i=1 to dim(var_list);
  VarName=vname(var_list(i));
Outcome=var_list[i];
 do j=1 to dim(categorical);
categorical_=vvalue(categorical(j));
do i=1 to dim(npredictors);
npredictors_=vname(npredictors(i));
format Depression Depressionn. Anxiety Anxietyy. interest interestt. depressed _depressedd. trouble_sleeping trouble_sleepingg. little_energy little_energyy. appetite appetitee.
feeling_bad feeling_badd. concentrating concentratingg. moving_slowly moving_slowlyy. hurting_yourself hurting_yourselff. PHQ9_SCORE PHQ9_SCORE_. PHQ2_SCORE PHQ2_SCORE.
 gender gender. race race. education_final education. insurance insurance. scalp_lesions scalp_lesionss. postauricular postauricularr. erythema erythemaa. eyelid_involvement eyelid_involvementt.
cheilitis cheilitiss. flexural_erythema flexural_erythemaa. xerosis xerosiss. neck_folds neck_foldss. nipple_eczema nipple_eczemaa. keratosis keratosiss. palmar palmarr. hand_eczema hand_eczemaa. ichthyosis ichthyosiss.
foot_eczema foot_eczemaa. age age_bin_. alopecia alopeciaa. pityriasis pityriasiss. pain painn. ;
 output;
end; end; end;
run; 
 proc print data=perm.temp; 
 run;
 proc sort data=perm.temp; by VarName; run;
proc glimmix data=perm.temp method=laplace order=internal; 
by VarName;
 class  record_id_final  npredictors_ categorical_;
 model outcome = npredictors_ categorical_ /link=cumlogit dist=multinomial solution;
  random visit /subject=record_id_final;
  run;
LOG:
292 data perm.temp; 293 set perm.mentalhealth; 294 array var_list[9] trouble_sleeping hurting_yourself interest depressed little_energy appetite 294! feeling_bad concentrating 295 moving_slowly; 296 array categorical[22] gender age scalp_lesions postauricular erythema eyelid_involvement 296! cheilitis flexural_erythema xerosis neck_folds nipple_eczema 297 keratosis palmar hand_eczema ichthyosis foot_eczema race education_final insurance alopecia 297! pityriasis pain; 298 array npredictors[9] SCORAD EASI BSA ADSI POEM_SCORE dlqi_score FIVED_SCORE RL_SCORE flare; 299 do i=1 to dim(var_list); 300 VarName=vname(var_list(i)); 301 Outcome=var_list[i]; 302 do j=1 to dim(categorical); 303 categorical_=vvalue(categorical(j)); 304 do i=1 to dim(npredictors); 305 npredictors_=vname(npredictors(i)); 306 format Depression Depressionn. Anxiety Anxietyy. interest interestt. depressed _depressedd. 306! trouble_sleeping trouble_sleepingg. little_energy little_energyy. appetite appetitee. 307 feeling_bad feeling_badd. concentrating concentratingg. moving_slowly moving_slowlyy. 307! hurting_yourself hurting_yourselff. PHQ9_SCORE PHQ9_SCORE_. PHQ2_SCORE PHQ2_SCORE. 308 gender gender. race race. education_final education. insurance insurance. scalp_lesions 308! scalp_lesionss. postauricular postauricularr. erythema erythemaa. eyelid_involvement 308! eyelid_involvementt. 309 cheilitis cheilitiss. flexural_erythema flexural_erythemaa. xerosis xerosiss. neck_folds 309! neck_foldss. nipple_eczema nipple_eczemaa. keratosis keratosiss. palmar palmarr. hand_eczema 309! hand_eczemaa. ichthyosis ichthyosiss. 310 foot_eczema foot_eczemaa. age age_bin_. alopecia alopeciaa. pityriasis pityriasiss. pain painn. ; 311 output; 312 end; end; end; 313 run; NOTE: There were 950 observations read from the data set PERM.MENTALHEALTH. NOTE: The data set PERM.TEMP has 188100 observations and 101 variables. NOTE: DATA statement used (Total process time): real time 0.18 seconds cpu time 0.18 seconds 314 proc sort data=perm.temp; by VarName; run; NOTE: There were 188100 observations read from the data set PERM.TEMP. NOTE: The data set PERM.TEMP has 188100 observations and 101 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.34 seconds cpu time 0.50 seconds 315 proc glimmix data=perm.temp method=laplace order=internal; 316 by VarName; 317 class record_id_final npredictors_ categorical_; 318 model outcome = npredictors_ categorical_ /link=cumlogit dist=multinomial solution; 319 random visit /subject=record_id_final; 320 run; NOTE: Some observations are not used in the analysis because of: missing response values (n=16038), missing fixed effects (n=9), missing subject effects (n=6534). NOTE: The GLIMMIX procedure is modeling the probabilities of levels of Outcome having lower Ordered Values in the Response Profile table. NOTE: Convergence criterion (FCONV=2.220446E-16) satisfied. NOTE: At least one element of the (projected) gradient is greater than 1e-3. NOTE: The above message was for the following BY group: VarName=trouble_sleeping NOTE: PROCEDURE GLIMMIX used (Total process time): real time 2:55.20 cpu time 2:54.98

schatr2_0-1635190237910.png

schatr2_1-1635190270931.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

If you look at dataset PERM.TEMP (great name, by the way) you would see you only have one response variable in there, indicating it wasn't created properly.

 

You can't have two do loops nested inside one another each with the index variable I. The third do loop should have index variable K.

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

If you look at dataset PERM.TEMP (great name, by the way) you would see you only have one response variable in there, indicating it wasn't created properly.

 

You can't have two do loops nested inside one another each with the index variable I. The third do loop should have index variable K.

--
Paige Miller
393310
Obsidian | Level 7
Thanks so much Paige! That fixed the issue perfectly. I really appreciate your help.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 797 views
  • 0 likes
  • 2 in conversation