BookmarkSubscribeRSS Feed
apatter3
Calcite | Level 5

I am trying to add four variables to create a score for each person and then create a new variable that has two categories: Engaged (>1 score) and not engaged (<=1). How would I go bout this or does anyone recommend a website or book to look at?

4 REPLIES 4
Reeza
Super User

Without knowing anything about your data or the rules you're trying to implement all we can kind of do is point you towards a tutorial. 

 

http://www.ats.ucla.edu/stat/sas/modules/vars.htm

 

In general, it's good to post what you have and what you want, we can help with the getting from A to B 🙂

apatter3
Calcite | Level 5

I am looking at engagement in regards to returning ASQs. I have ASQ2, ASQ4, ASQ8, and ASQ12. I want to add the ASQs to create a score for each person and then create a new variable that has two categories: Engagement (>1 score) and not engaged (<=1).

 

IF _2_MONTH_ASQ='Yes' THEN ASQ2=1;
ELSE IF _2_MONTH_ASQ='No' THEN ASQ2=0;
ELSE ASQ2=.;
 
IF _4_MONTH_ASQ='Yes' THEN ASQ4=1;
ELSE IF _4_MONTH_ASQ='No' THEN ASQ4=0;
ELSE ASQ4=.;
 
IF _8_MONTH_ASQ='Yes' THEN ASQ8=1;
ELSE IF _8_MONTH_ASQ='No' THEN ASQ8=0;
ELSE ASQ8=.;
 
IF _12_MONTH_ASQ='Yes' THEN ASQ12=1;
ELSE IF _12_MONTH_ASQ='No' THEN ASQ12=0;
ELSE ASQ12=.;
Jagadishkatam
Amethyst | Level 16

Once you have the ASQs variable created as per your previous post. Please use the sum funtion as below to get the sum of the ASQs to create a score variable

 

scoren=sum(of ASQ2-ASQ12);
if scoren>1 then score='>1 ';
else if scoren<=1 then score='<=1';

 

Thanks,
Jag
PGStats
Opal | Level 21

You could  create your score directly from the _2_MONTH_ASQ etc. variables. But assuming you need the ASQ2 etc. variables for some other purpose, your score could be

 

if sum(ASQ2, ASQ4, ASQ8, ASQ12) <= 1
	then score = "Not engaged";
	else score = "Engagement";

Note that if all ASQ2 etc. variables are missing, the score will be Not engaged.

 

PG

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!

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.

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
  • 4 replies
  • 589 views
  • 1 like
  • 4 in conversation