Hello SAS Community,
I want to create a new version of an existing variable that only includes the scores of that existing variable if they correspond to a specific score on another variable. I'm not sure if that makes sense - I've only been using SAS for a month or two. The "str_e2_sq" variable is the severity rating (1 - 4) of a particular stressful life event and the "foc_e2" variable is the rating (1 - 4) of the focus of that event (self, joint, other, pet/possession). So, I'm trying to create variable of severity ratings by the focus of the stressful life event.
This the code I thought would work:
Data = DHEASLES.sles_master;
set = DHEASLES.sles_master;
IF foc_e2 = 1 AND str_e2_sq GE . then str_e2_sq_new = str_e2_sq;
ELSE str_e2_sq_new = .;
run;
I got the following errors:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69
70 Data = DHEASLES.sles_master;
____
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
71 set = DHEASLES.sles_master;
___
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
72 IF foc_e2 = 1 AND str_e2_sq GE . then str_e2_sq_new = str_e2_sq;
__
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
73 ELSE str_e2_sq_new = .;
____
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
74 run;
75
76 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
86
Thank you so much for the help!
Best,
Joe