I dont have any data but i have to give a sample code for how i would solve such a problem.
the problem is to Create a variable decision_pt that sums the occurences of the following
data a; set a; retain decision_pt = 0; if age < 45 then decision_pt =decision_pt +1 ; if state ="URBAN" or "HIGHLY URBAN" decision_pt =decision_pt +1 ;
am i on the right track?
You can't expect us here in SAS Communities to do your homework for you! You will not learn anything that way.
So here's my suggestion: you write some SAS code to do this, and if you can't get it to work, show us the code and the SASLOG, and someone here will know how to fix it.
i modified the question with my answer now. hope this helps.
Seems like this could produce the desired answer, once you clean up your syntax errors.
if state ="URBAN" or state="HIGHLY URBAN" then decision_pt =decision_pt +1 ;
Is adding retain important here?
RETAIN probably isn't needed here, and may have undesired effects.
I think you want
decision_pt=0;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.