Hello, I know the title isn't very clear and I apologize for that and here is some info to help make what I'm asking about make more sense:
I am a first-semester student in a social science/human ecology PhD program, so I am looking at behaviors and outcomes and pretty new to this. I am using a secondary dataset and I am trying to create a scale variable (that has been created and used this way in other research- though was concerned with a different outcome/relationships. Including using the same secondary data I am using- though from a different wave of the data). I am not concerned with the degree to which a certain behavior or circumstance is present, just whether or not it is present and the effect of that on a particular outcome.
Right now I have created 10 binary dummy variables that are either 0 or 1 (0=behavior/circumstance is not present, 1=behavior/circumstance is present). I want to now create a new variable that will add up the dummy variables to have a value of 0-10, so that in the end the variable will represent a score from 0-10. I just am not sure how to do that from here.
Thank you for any help/direction.
Thank you!
I kept getting an error, so I searched using the sum terminology and was able to search for that for other options. So I just wanted to follow up with what I ended up doing that seems to have worked. I don't know enough about SAS to know why or why not, but wanted to follow up to make sure this looked alright?
DATA work.set_SAS; SET filesave.set_SAS;
/*creating new variable for scale*/
NEW=.;
/*recoding new variable for scale*/
NEW=var1-var2-var3-var4-var5-var6-var7-var8-var9-var10;
LABEL NEW= "Scale (0-10)";
RUN;
If you post the log with the error, it should be easy to diagnose.
Your formula runs without error, but isn't the same thing. You would need to change the minus signs to plus signs to get the right result.
Thank you!
If you use the + instead of Sum you get missing value result if any of the variables have missing values. So that is something to consider as well.
data example; v1 =1; v2 =0; v3 =.; v4 = 3; v5 = 4; tot = v1 + v2 + v3 + v4 + v5; total = sum (of v1-v5); run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.