Hi,
I have the following dataset sample:
Name Year Sick
Al 2012 0
Al 2013 1
Al 2014 0
Al 2015 0
Jay 2012 0
Jay 2013 0
Jay 2014 0
Jay 2015 0
From this dataset, I need to create a flag variable which equals one if the employee EVER being sick in any of the years, and zero otherwise. In other words, my data should look like this:
Name Year Sick Flag
Al 2012 0 1
Al 2013 1 1
Al 2014 0 1
Al 2015 0 1
Jay 2012 0 0
Jay 2013 0 0
Jay 2014 0 0
Jay 2015 0 0
I am not sure how to do this in SAS Base or in EG. If I have the correct code, I can run it from within EG.
Thanks,
Altijani
@altijani You probably shouldn't include your phone number here.
This is a public forum with it's share of spammers.
To do this in EG, you can use Query Builder and create a new summary column that is the MAX of SICK variable and group by Name.
UNTESTED CODE
proc sql; create table want as select *,max(sick) as flag from have group by name; quit;
@altijani You probably shouldn't include your phone number here.
This is a public forum with it's share of spammers.
To do this in EG, you can use Query Builder and create a new summary column that is the MAX of SICK variable and group by Name.
Many thanks for the solution, and for pointing out the issue of my phone number. It was done by mistake, and now it is out. Hope not many spammers got a hold of it 😞
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.