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

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
  • 1005 views
  • 1 like
  • 2 in conversation