Help using Base SAS procedures

array?

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

array?

Hi,

please help me do this

all dates are in date9. format

do I need an array???
/*HAVE*/
admit_dt  Pdate1      date2    Pdate3     Pdate4     Pdate5
01OCT13   02oct13   09oct13   11oct13   15oct13     01OCT13

/*logic*/
Pdate1-admit_dt=PRday1
Pdate2-admit_dt=PRday2
Pdate3-admit_dt=PRday3
Pdate4-admit_dt=PRday4
Pdate5-admit_dt=PRday5

/*WANT*/

admit_dt  Pdate1   Pdate2   Pdate3      Pdate4      Pdate5           PRday1 PRday2 PRday3 PRday4 PRday5
01OCT13   02oct13 09oct13   11oct13   15oct13      01OCT13        1           8             10         14         0

Thanks


Accepted Solutions
Solution
‎06-04-2014 03:08 PM
Super User
Posts: 17,775

Re: array?

The only possible mistake I see is that you have Admit_date1 rather than Admit_date in your example above.

Other than that it should work, if it doesn't you'll have to post the error or why it isn't.

View solution in original post


All Replies
Super User
Posts: 17,775

Re: array?

robertrao wrote:

/*logic*/
Pdate1-admit_dt=PRday1
Pdate2-admit_dt=PRday2
Pdate3-admit_dt=PRday3
Pdate4-admit_dt=PRday4
Pdate5-admit_dt=PRday5

You don't need an array but it helps avoid the repetition of code.

What have you tried?

You can flip the above for starters:

PRDay1=Pdate1-admit_dt to get what you need without going into arrays.

Super Contributor
Posts: 1,040

Re: array?

thanks for the reply.

I wanted to write the way you mentioned.

But there are 65 Pdate's

so I was trying to see if there is any easier way???

Thanks

Super User
Posts: 17,775

Re: array?

You've asked at least a dozen questions on arrays here. While I don't mind helping, you should try to do some of it on your own otherwise you'll always be dependent on the forum.

Super Contributor
Posts: 1,040

Re: array?

hmmm

it has always been a learning process for me.

this is what I tried

please correct me

thanks

data array;

set demog;

array prox{*} PROCDT1-PROCDT65;

array pr{*}   PRDAY1-PRDAY65;

do i=1 to dim(prox);

pr{i}=prox{i}-ADMIT_DATE1;

end;

run;

Solution
‎06-04-2014 03:08 PM
Super User
Posts: 17,775

Re: array?

The only possible mistake I see is that you have Admit_date1 rather than Admit_date in your example above.

Other than that it should work, if it doesn't you'll have to post the error or why it isn't.

Super Contributor
Posts: 1,040

Re: array?

thanks you so very much.

I get some results.

Thanks

☑ This topic is SOLVED.

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

Discussion stats
  • 6 replies
  • 250 views
  • 1 like
  • 2 in conversation