Hi,
I have the following datasets;
Could some one tell me the right approach?
I have two tables
Table1
(no repeats by mrn)
e and i are dates.The order of these variables may vary...
like after i2 i might have e3 e4 e5 and then may come i3
and all of these may not necessarily have a date
mrn e1 i1 e2 i2
999 jun12012 june222012 aug012012 aug102012
Regards
1. Run a proc sql to merge all the data together.
2. Using a datastep create an array that is coded such as array dates(25) e1-e10 i1-15;
3. Use a do loop to go through each entry and if dates(i) between admit_date and discharge_date then new_id=visit_id.
Post some sample output please, including what happens if the e1 is between adm and discharge and i1 is not.
Also, what is stopping you from merging them? And what makes you think you need arrays if you're only looking at e1 and i1?
hi ,
we can use PROC FORMAT..!!
Regards
ALLU
proc format;
value trace_id
'29MAY2012'D - < '12JUL2012'D = '101'
'05AUG2012'D - '22AUG2012'D = '102'
'01SEP2012'D - '05SEP2012'D = '102'
;
RUN;
DATA TABLE1;
infile datalines truncover;
INPUT MRN E1 date9. i1 date9.;
format E1 trace_id.;
FORMAT i1 trace_id.;
datalines;
999 12jun201222JUN2012
;
run;
Example output?
1. Run a proc sql to merge all the data together.
2. Using a datastep create an array that is coded such as array dates(25) e1-e10 i1-15;
3. Use a do loop to go through each entry and if dates(i) between admit_date and discharge_date then new_id=visit_id.
BETWEEN is an SQL language construct. You could use it in a WHERE statement , but not in an IF statement.
The equivalent SAS syntax would by
admit_date <= dates{i} <= dis_date
Create two arrays.
But it looks like they're different sizes, so what comparison do you want when you hit i12?
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.
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.