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,

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

6 REPLIES 6
Reeza
Super User

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.

robertrao
Quartz | Level 8

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

Reeza
Super User

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.

robertrao
Quartz | Level 8

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;

Reeza
Super User

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.

robertrao
Quartz | Level 8

thanks you so very much.

I get some results.

Thanks

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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