BookmarkSubscribeRSS Feed
michelle05
Fluorite | Level 6

Good morning,

I have to restructure this data using the repeated statement of PROC GLM or PROC MIXED.  I'm only to do this for LDL cholesterol and include in the model GENDER, LDL_A, LDL_B, LDL_C.  Here's what I have so far:

 

DATA STATIN;
DO SUBJ = 1 TO 20;
IF RANUNI (1557) LT .5 THEN GENDER = 'FEMALE';
ELSE GENDER = 'MALE';
IF RANUNI (0) LT .3 THEN DIET = 'HIGH FAT';
ELSE DIET = 'LOW FAT';
DO DRUG = 'A', 'B', 'C';
LDL = ROUND(RANNOR(1557)*20 +110
+ 5* (DRUG EQ 'A')
- 10*(DRUG EQ 'B')
- 5* (GENDER EQ 'FEMALE')
+ 10*(DIET EQ 'HIGH FAT'));
HDL = ROUND(RANNOR(1557)*10 + 20
+ .2*LDL
+ 12*(DRUG EQ 'B'));
TOTAL = ROUND(RANNOR (1557)*20 + LDL + HDL + 50
- 10*(GENDER EQ 'FEMALE')
+ 10*(DIET EQ 'HIGH FAT'));
OUTPUT;
END;
END;
RUN;
PROC MIXED DATA= STATIN;
CLASS SUBJ DRUG;
MODEL LDL=DRUG;
RANDOM SUBJ;
SET STATIN;
IF DRUG = 'A'THEN OUTPUT ONE;
ELSE IF DRUG = 'B'THEN OUTPUT TWO;
ELSE IF DRUG = 'C' THEN OUPUT THREE;
PROC SORT DATA = ONE (RENAME=(LDL=LDL_A));
BY SUBJ;
PROC SORT DATA = TWO (RENAME=(LDL=LDL_B));
BY SUBJ;
PROC SORT DATA = THREE (RENAME=(LDL=LDL_C));
BY SUBJ;
DATA MRG;
MERGE ONE TWO THREE;
BY SUBJ;
PROC GLM DATA = MRG;
MODEL LDL_A LDL_B LDL_C=/NOUNI;
REPEATED DRUG 3 (1 2 3);
RUN;

 This is the error that I'm getting:

NOTE: The SAS System stopped processing this step because of errors.
94 CLASS SUBJ DRUG;
95 MODEL LDL=DRUG;
96 RANDOM SUBJ;
97 SET STATIN;
___
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
98 IF DRUG = 'A'THEN OUTPUT ONE;
99 ELSE IF DRUG = 'B'THEN OUTPUT TWO;
100 ELSE IF DRUG = 'C' THEN OUPUT THREE;
 
 
101 PROC SORT DATA = ONE (RENAME=(LDL=LDL_A));
ERROR: File WORK.ONE.DATA does not exist.
102 BY SUBJ;
103 PROC SORT DATA = TWO (RENAME=(LDL=LDL_B));
ERROR: File WORK.TWO.DATA does not exist.
104 BY SUBJ;
 
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 353.21k
OS Memory 34724.00k
Timestamp 10/22/2019 02:22:28 PM
Step Count 222 Switch Count 0
Page Faults 0
Page Reclaims 15
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
 
 
 
105 PROC SORT DATA = THREE (RENAME=(LDL=LDL_C));
ERROR: File WORK.THREE.DATA does not exist.
106 BY SUBJ;
 
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 352.43k
OS Memory 34724.00k
Timestamp 10/22/2019 02:22:28 PM
Step Count 223 Switch Count 0
Page Faults 0
Page Reclaims 15
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
 
 
 
107 DATA MRG;
108 MERGE ONE TWO THREE;
ERROR: File WORK.ONE.DATA does not exist.
ERROR: File WORK.TWO.DATA does not exist.
ERROR: File WORK.THREE.DATA does not exist.
109 BY SUBJ;
110 PROC GLM DATA = MRG;
111 MODEL LDL_A LDL_B LDL_C=/NOUNI;
ERROR: Variable LDL_A not found.
ERROR: Variable LDL_B not found.
ERROR: Variable LDL_C not found.
NOTE: The previous statement has been deleted.
112 REPEATED DRUG 3 (1 2 3);
113 RUN;
 
ERROR: A MODEL statement must be given.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE GLM used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 509.65k
OS Memory 34724.00k
Timestamp 10/22/2019 02:22:28 PM
Step Count 225 Switch Count 0
Page Faults 0
Page Reclaims 15
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
 
 
2 REPLIES 2
ballardw
Super User

The SET statement is not valid for Proc Mixed.

 

I would guess that for some reason you started to write Proc Mixed syntax and then decided you needed to do something with the data and didn't move or remove the proc mixed syntax.

Also seeing code like:

SET STATIN;
IF DRUG = 'A'THEN OUTPUT ONE;
ELSE IF DRUG = 'B'THEN OUTPUT TWO;
ELSE IF DRUG = 'C' THEN OUPUT THREE;

makes me think that you intended to have

 

data one two three;
SET STATIN;
IF DRUG = 'A'THEN OUTPUT ONE;
ELSE IF DRUG = 'B'THEN OUTPUT TWO;
ELSE IF DRUG = 'C' THEN OUPUT THREE;
michelle05
Fluorite | Level 6

Yes, you are absolutely right.  I did start with that and then I started questioning myself.  Thank you for taking out the time to help me on this.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 524 views
  • 0 likes
  • 2 in conversation