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

Hi All,

I would like to create a new variable (health) using 3 variables which are already in the dataset (q1 q2 and q3). The three variables I am creating this new variable from all have the same ordinal response options. (How long in hours have you missed work, due two three separate conditions)

After creating this new variable(health) from the 3 variables,  I would like to get its mean, SD, CI. 

Thank you in advance for any advice you may have!

Regards

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

proc means data=have n mean std ;

var health;

run;

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Number hours of missed work seems like it is numeric, not ordinal.

But, we cannot tell you how to combine the 3 variables, this is your problem, and so you have to decide how to combine them, and then we might be able to advise on how to code it in SAS.

--
Paige Miller
GregBond
Obsidian | Level 7

Thanks for your response Paige!

Combining the variables through addition, e.g. health = Q54+Q55+Q56.

Then, I would like to get the mean, SD, and CI of the 'health' variable sum.

Reeza
Super User

proc means data=have n mean std ;

var health;

run;

GregBond
Obsidian | Level 7

thanks for your response again, when running this code...

data work.CAREGIVER;

set work.caregiver;

length health $44;

keep health ;

health = Q54+Q55+Q56;

run;

proc means data=work.CAREGIVER n mean std;

var health ;

run;

I get the following error...

  proc means data=work.CAREGIVER_SPSS n mean std;var house;

ERROR: Variable house in list does not match type prescribed for this list.

  run;

Reeza
Super User

That's because you've created a character variable above, not a numeric variable.  Why do you have the length statement?

PaigeMiller
Diamond | Level 26

Yes, you shouldn't need the length statement, and I am still concerned that you consider the number of hours missed to be "ordinal".

Are the values of Q54 and Q55 and Q56 actual numbers, as in SAS variables that are numeric?

--
Paige Miller

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1647 views
  • 9 likes
  • 3 in conversation