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:
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;
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.