BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
altijani
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@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. 

 

delete_eg_summary.JPG

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

UNTESTED CODE

 

proc sql;
    create table want as select *,max(sick) as flag from have group by name;
quit;
--
Paige Miller
Reeza
Super User

@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. 

 

delete_eg_summary.JPG

altijani
Quartz | Level 8

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 😞

sas-innovate-2024.png

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.

 

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
  • 3 replies
  • 1712 views
  • 0 likes
  • 3 in conversation