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

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 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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.

View solution in original post

6 REPLIES 6
Reeza
Super User

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?

allurai0412
Fluorite | Level 6

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;

Reeza
Super User

Example output?

Reeza
Super User

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.

Tom
Super User Tom
Super User

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

Reeza
Super User

Create two arrays.

But it looks like they're different sizes, so what comparison do you want when you hit i12?

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!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 837 views
  • 3 likes
  • 4 in conversation