Help using Base SAS procedures

Array Task?

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,040
Accepted Solution

Array Task?

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


Accepted Solutions
Solution
‎04-18-2013 05:24 PM
Super User
Posts: 17,824

Re: Array Task?

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


All Replies
Super User
Posts: 17,824

Re: Array Task?

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?

Frequent Contributor
Posts: 97

Re: Array Task?

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;

Super User
Posts: 17,824

Re: Array Task?

Example output?

Solution
‎04-18-2013 05:24 PM
Super User
Posts: 17,824

Re: Array Task?

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.

Super User
Super User
Posts: 6,500

Re: Array Task?

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

Super User
Posts: 17,824

Re: Array Task?

Create two arrays.

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

☑ This topic is SOLVED.

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

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