SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Data Manipulation

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 11
Accepted Solution

Data Manipulation

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!

 

 


Accepted Solutions
Solution
‎11-17-2015 05:30 PM
Super User
Posts: 10,550

Re: Data Manipulation

If I understand what you are attempting;

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

View solution in original post


All Replies
Solution
‎11-17-2015 05:30 PM
Super User
Posts: 10,550

Re: Data Manipulation

If I understand what you are attempting;

Data want;
   set have;
   do date3 = date1 to date2;
        output;
   end;
run;
Occasional Contributor
Posts: 11

Re: Data Manipulation

Thank you! I'll try that!

Frequent Contributor
Posts: 83

Re: Data Manipulation

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;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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