Hi everyone,
This seems like a simple problem but I can't figure it out. I want to repeat rows between two years by group.
here is a sample of my data:
data have;
input id name $ role $ year1 year2;
datalines;
1 Jon CEO 2000 2004
2 Mike President 2006 2008
3 George Advisor 2010 2010
;
And here is what I am looking for.
id | name | role | year1 | year2 | year3 |
1 | Jon | CEO | 2000 | 2004 | 2000 |
1 | Jon | CEO | 2000 | 2004 | 2001 |
1 | Jon | CEO | 2000 | 2004 | 2002 |
1 | Jon | CEO | 2000 | 2004 | 2003 |
1 | Jon | CEO | 2000 | 2004 | 2004 |
2 | Mike | President | 2006 | 2008 | 2006 |
2 | Mike | President | 2006 | 2008 | 2007 |
2 | Mike | President | 2006 | 2008 | 2008 |
3 | George | Advisor | 2010 | 2010 | 2010 |
Thank you!
Try this 🙂
data have;
input id name $ role $ year1 year2;
datalines;
1 Jon CEO 2000 2004
2 Mike President 2006 2008
3 George Advisor 2010 2010
;
data want;
set have;
do year3 = year1 to year2;
output;
end;
run;
Try this 🙂
data have;
input id name $ role $ year1 year2;
datalines;
1 Jon CEO 2000 2004
2 Mike President 2006 2008
3 George Advisor 2010 2010
;
data want;
set have;
do year3 = year1 to year2;
output;
end;
run;
Anytime
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: