BookmarkSubscribeRSS Feed
kplbug
Calcite | Level 5

Hello!

 

I am very new to SAS and therefore might not include all the information needed for this question to be answered successfully but I'll try. I but need to use it for work though and need to figure out how to include multiple values to an input (I think). To sum up my code, we have 30 subjects and on each subject at week 2, for example, we had two evaluators rate them for body condition on a scale of 1-5. I'd like to include both values from each assessor to each subject, but am unsure how to do that. Here is my code with the value of one assessor which works fine:

 

/*ANOVA Code*/

Data BodyCondition;

                infile datalines dlm='09'x;

                input	PatientID	Treatment$	Week	Age	Sex$	BodyCondition;

                datalines; 
1	TreatmentA	0	14	F	4.5
1	TreatmentA	2	14	F	4.5
1	TreatmentA	4	14	F	4
1	TreatmentA	10	14	F	4
1	TreatmentA	16	14	F	4
2	TreatmentB	0	3	F	5
2	TreatmentB	2	3	F	5
2	TreatmentB	4	3	F	5
2	TreatmentB	10	3	F	5
2	TreatmentB	16	3	F	5

;

RUN;

Proc freq data=BodyCondition;

  table age sex treatment;

Run;

Proc Print data=BodyCondition;

Run;

Proc glimmix data=BodyCondition;

  Weekx = Week;

  class PatientID Treatment Week Sex;

  model BodyCondition = Treatment|Week  Week|Sex age/ ddfm=kr;

  random Week / subject=PatientID type=cs residual;

  lsmeans Treatment|Week / pdiff adjust=tukey lines;

  lsmeans Week|Sex / pdiff adjust=tukey lines;

  output out=second predicted=pred residual=resid

residual(noblup)=mresid student=studentresid student(noblup)=smresid;

Run;
Proc sgplot data=second;

                vbox smresid / group=Treatment datalabel;

Run;
Proc sgplot data=second;

                vbox smresid / group=Week datalabel;

Run;
Proc sgscatter data=second;

                plot studentresid*(pred Week Treatment);
                
Run;
Proc univariate data=second normal plot;

                var studentresid;
Run;

So in the code above I have one value for "BodyCondition", but I would like each patient to have 2 values for this. From what I've seen other people do I tried doing this:

/*ANOVA Code*/

Data BodyCondition;

                infile datalines dlm='09'x;

                input	PatientID	Treatment$	Week	Age	Sex$	BodyCondition1-BodyCondition2;

                datalines; 
1	TreatmentA	0	14	F	4.5	5
1	TreatmentA	2	14	F	4.5 	4
1	TreatmentA	4	14	F	4	4.5
1	TreatmentA	10	14	F	4	4.5
1	TreatmentA	16	14	F	4	4
2	TreatmentB	0	3	F	5	5
2	TreatmentB	2	3	F	5	4.5
2	TreatmentB	4	3	F	5	5
2	TreatmentB	10	3	F	5	5
2	TreatmentB	16	3	F	5	4.5

I made the BodyCondition input into "BodyCondition1-BodyCondition2". However, if I only change that, the errors that come up are "ERROR: Response variable BodyCondition is not in the data set and is not defined through programming statements.", "ERROR: Variable SMRESID not found. ERROR: Variable TREATMENT not found.", "ERROR: Variable SMRESID not found. ERROR: Variable WEEK not found.", which makes sense, but if I change all BodyCondition to BodyCondition1-BodyCondition2 then it just won't even run the results at all because it is so messed up. Really just need to find a way to include two body condition scores from the two different evaluators evaluating the same thing per patient. 

 

I hope I've included enough information- I am pretty stuck as I can't reach out for help from anyone until next week. Appreciate any help! Thank you

 

 

8 REPLIES 8
ballardw
Super User

Please show the log for the entire Proc Glimmix that throws those errors. All the code for the proc and messages from the log.

 

The particular error looks like you are possibly still using the

Model bodycondition =

but the replacement data set you show does not have that variable.

Reeza
Super User
I think you're asking a more theoretical than practical question. You want to know how to handle two variables who are highly correlated in your model. I don't think it would be valid to include both as they're often the same. I would instead consider including one and the difference between the two. If the difference ends up being statistically significant I think that would indicate that the different rating is a factor and you need to consider it somehow. Other options are to average the two, take the highest or lowest values consistently.

If I am wrong and you're looking for technical help to run this code, you need to provide a replicable code, data and/or the log to provide us with enough information to help you out.
PaigeMiller
Diamond | Level 26

Hello @kplbug , from now on, when you get an ERROR in the log, show us the ENTIRE log for the step involved, in this case we would need to see the ENTIRE log from PROC GLIMMIX (that's 100% of the log from PROC GLIMMIX, every single character, do not chop anything out, so we can see the code as it appears in the log, plus any NOTEs, WARNINGs or ERRORs, exactly as it appears in the log). This will get you a faster answer and a better answer. So, every time there's an error in the LOG, show us the log.

 

"ERROR: Response variable BodyCondition is not in the data set and is not defined through programming statements."

 

Your data set, after you make the change, does not have a variable named bodycondition. It has variables named bodycondition1 and bodycondition2. This is the problem. You need to point GLIMMIX to use either or both of bodycondition1 and bodycondition2.

 

 

 

 

--
Paige Miller
kplbug
Calcite | Level 5

Hello!

 

I am very new to SAS and therefore might not include all the information needed for this question to be answered successfully but I'll try. I but need to use it for work though and need to figure out how to include multiple values to an input (I think). To sum up my code, we have 30 subjects and on each subject at week 2, for example, we had two evaluators rate them for body condition on a scale of 1-5. I'd like to include both values from each assessor to each subject, but am unsure how to do that. Here is my code with the value of one assessor: 

 

 

/*ANOVA Code*/
Data BodyCondition;

                infile datalines dlm='09'x;

                input	PatientID Treatment$	Week	Age	Sex$	BodyCondition;

                datalines; 

1 TreatmentA 0 14 F 4.5
1 TreatmentA 2 14 F 4.5
1 TreatmentA 4 14 F 4
1 TreatmentA 10 14 F 4
1 TreatmentA 16 14 F 4
2 TreatmentB 0 3 F 5
2 Treatment B 2 3 F 5
2 Treatment B 4 3 F 5
2 TreatmentB 10 3 F 5
2 TreatmentB 16 3 F 5
... and it continues to a proc glimmix

The goal would be to include two values for body condition score, one from each assessor. I was thinking it could be something along the lines of "BodyCondition1-BodyCondition2", but I am still receiving multiple errors. 

 

Any help would be greatly appreciated! Thanks so much

 

 

Quentin
Super User

Hi,

 

Please show the code you have tried, and include the log showing the error.

 

It's not clear from your question if you're having a problem with the DATA step code to create the dataset, or the PROC GLIMMIX step which analyzes it.

 

A small executable example which illustrates the problem would help people help you.

 

--Q.

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
kplbug
Calcite | Level 5

Hi, thanks for letting me know- I did end up making a new post because it was easier for me to re-collect my thoughts that way but here is all my info:

 

Hello!

 

I am very new to SAS and therefore might not include all the information needed for this question to be answered successfully but I'll try. I but need to use it for work though and need to figure out how to include multiple values to an input (I think). To sum up my code, we have 30 subjects and on each subject at week 2, for example, we had two evaluators rate them for body condition on a scale of 1-5. I'd like to include both values from each assessor to each subject, but am unsure how to do that. Here is my code with the value of one assessor which works fine:

 

/*ANOVA Code*/

Data BodyCondition;

                infile datalines dlm='09'x;

                input	PatientID	Treatment$	Week	Age	Sex$	BodyCondition;

                datalines; 
1	TreatmentA	0	14	F	4.5
1	TreatmentA	2	14	F	4.5
1	TreatmentA	4	14	F	4
1	TreatmentA	10	14	F	4
1	TreatmentA	16	14	F	4
2	TreatmentB	0	3	F	5
2	TreatmentB	2	3	F	5
2	TreatmentB	4	3	F	5
2	TreatmentB	10	3	F	5
2	TreatmentB	16	3	F	5

;

RUN;

Proc freq data=BodyCondition;

  table age sex treatment;

Run;

Proc Print data=BodyCondition;

Run;

Proc glimmix data=BodyCondition;

  Weekx = Week;

  class PatientID Treatment Week Sex;

  model BodyCondition = Treatment|Week  Week|Sex age/ ddfm=kr;

  random Week / subject=PatientID type=cs residual;

  lsmeans Treatment|Week / pdiff adjust=tukey lines;

  lsmeans Week|Sex / pdiff adjust=tukey lines;

  output out=second predicted=pred residual=resid

residual(noblup)=mresid student=studentresid student(noblup)=smresid;

Run;
Proc sgplot data=second;

                vbox smresid / group=Treatment datalabel;

Run;
Proc sgplot data=second;

                vbox smresid / group=Week datalabel;

Run;
Proc sgscatter data=second;

                plot studentresid*(pred Week Treatment);
                
Run;
Proc univariate data=second normal plot;

                var studentresid;
Run;

So in the code above I have one value for "BodyCondition", but I would like each patient to have 2 values for this. From what I've seen other people do I tried doing this:

/*ANOVA Code*/

Data BodyCondition;

                infile datalines dlm='09'x;

                input	PatientID	Treatment$	Week	Age	Sex$	BodyCondition1-BodyCondition2;

                datalines; 
1	TreatmentA	0	14	F	4.5	5
1	TreatmentA	2	14	F	4.5 	4
1	TreatmentA	4	14	F	4	4.5
1	TreatmentA	10	14	F	4	4.5
1	TreatmentA	16	14	F	4	4
2	TreatmentB	0	3	F	5	5
2	TreatmentB	2	3	F	5	4.5
2	TreatmentB	4	3	F	5	5
2	TreatmentB	10	3	F	5	5
2	TreatmentB	16	3	F	5	4.5

I made the BodyCondition input into "BodyCondition1-BodyCondition2". However, if I only change that, the errors that come up are "ERROR: Response variable BodyCondition is not in the data set and is not defined through programming statements.", "ERROR: Variable SMRESID not found. ERROR: Variable TREATMENT not found.", "ERROR: Variable SMRESID not found. ERROR: Variable WEEK not found.", which makes sense, but if I change all BodyCondition to BodyCondition1-BodyCondition2 then it just won't even run the results at all because it is so messed up. Really just need to find a way to include two body condition scores from the two different evaluators evaluating the same thing per patient. 

 

I hope I've included enough information- I am pretty stuck as I can't reach out for help from anyone until next week. Appreciate any help! Thank you

PaigeMiller
Diamond | Level 26

Duplicate thread. Please continue the discussion at https://communities.sas.com/t5/New-SAS-User/How-to-add-2-values-to-one-input-parameter/td-p/745920/j....

 

@kplbug, please do not post the same question twice.

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 891 views
  • 0 likes
  • 6 in conversation