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

HI, I have a large database that needs to be manipulated. I want to convert the data that looks like this:

 

iddate1date2var1var2
12005200853
22006200812

 

to something that looks like this:

 

iddate1date2date3var1var2
120052008200553
120052008200653
120052008200753
120052008200853
220062008200612
220062008200712
220062008200812

 

Basically, I want to convert each observation into id-years.

 

what is the best and most efficient way to do this?

 

Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If I understand what you are attempting;

Data want;
   set have;
   do date3 = date1 to date2;
        output;
   end;
run;

View solution in original post

3 REPLIES 3
ballardw
Super User

If I understand what you are attempting;

Data want;
   set have;
   do date3 = date1 to date2;
        output;
   end;
run;
katie80
Fluorite | Level 6

Thank you! I'll try that!

Jim_G
Pyrite | Level 9

data one;
input id: date1: date2: var1: var2:;
dur=date2-date1+1; date3=date1;
do x=1 to dur;
output;
date3+1;
end;
cards;
1 2005 2008 5 3
2 2006 2008 1 2
;
proc print; run;

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 906 views
  • 0 likes
  • 3 in conversation