in end i do not able to get value for end date seprately or so,,,,
You need to explain. The code and example I sent would provide values for start and/or enddates if either or both exist in your file.
THANKS FOR THE HELP BUT LOOK LIKE THE DATASET TO BEGEN WITH IS CURREPT AND I NEED TO WORK ON THAT DETAILS FIRST TO START WITH ,,,,,AS SO SORRY FOR TROUBLE,,,,,,AND THANKS FOR THE REPLY AND SUGGESTION,,,,
The basic idea of interleaving records from two (or more) dataset in ID order can by done with SET and BY statements.
Did you want to more than that?
data one;
input serial start $15. ;
cards;
101 jan2008
101 feb2008
101 march2008
102 feb2007
102 march2007
102 april2007
run;
data two ;
input serial end $15.;
101 july2007
101 aug2007
101 sept2007
102 may2008
102 june2008
102 july2008
run;
data both ;
set one two;
by serial;
run;
Output:
Obs serial start end
1 101 jan2008
2 101 feb2008
3 101 march2008
4 101 july2007
5 101 aug2007
6 101 sept2007
7 102 feb2007
8 102 march2007
9 102 april2007
10 102 may2008
11 102 june2008
12 102 july200
Now if you want to also order by the date then you will need to first give it real dates and then copy the start and end dates to another variable that you can use to order.
data one;
format serial 5. date start date9.;
input serial start date9. ;
date=start;
cards;
101 01jan2008
101 01feb2008
101 01mar2008
102 01feb2007
102 01mar2007
102 01apr2007
run;
data two ;
format serial 5. date end date9.;
input serial end date9.;
date=end;
cards;
101 01jul2007
101 01aug2007
101 01sep2007
102 01may2008
102 01jun2008
102 01jul2008
run;
data both ;
set one two;
by serial date ;
run;
options nocenter nodate nonumber linesize=50;
proc print width=min;
run;
Obs serial date start end
1 101 01JUL2007 . 01JUL2007
2 101 01AUG2007 . 01AUG2007
3 101 01SEP2007 . 01SEP2007
4 101 01JAN2008 01JAN2008 .
5 101 01FEB2008 01FEB2008 .
6 101 01MAR2008 01MAR2008 .
7 102 01FEB2007 01FEB2007 .
8 102 01MAR2007 01MAR2007 .
9 102 01APR2007 01APR2007 .
10 102 01MAY2008 . 01MAY2008
11 102 01JUN2008 . 01JUN2008
12 102 01JUL2008 . 01JUL2008
SQL can do it easily.
data one; input serial start $15. ; cards; 101 jan2008 101 feb2008 101 march2008 102 feb2007 102 march2007 102 april2007 ; run; data two ; input serial end $15.; cards; 101 july2007 101 aug2007 101 sept2007 102 may2008 102 june2008 102 july2008 ; run; proc sql ; create table want as select * from one where serial in (select distinct serial from two) outer union corresponding select * from two where serial in (select distinct serial from one); quit; proc sort data=want;by serial;run;
Ksharp
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.