BookmarkSubscribeRSS Feed
malikah_sph
Calcite | Level 5

I need help trying to keep the variable admitDate formatted in the following code:

 

proc transpose data=temp
out=analysis
prefix=admitDate;
format admitDate yymmdd10.;
by patientId;
var age systolic procedure1 procedure2 procedure3 procedure4 procedure5 diagnosis1 diagnosis2 diagnosis3 diagnosis4 diagnosis5;
run;

 

**When I run it it gives the date as numbers. Is there a better way to do this?

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, the best way is not to put data as column names.  Column names are there for your programming benefit, to ake your coding simpler and easier.  Creating columsn with numbers/dates or anything else will just make your life harder.  Prefix option is there give you a constant prefeix for all the data in the array, so you can refer to things via shorthand:

procedure:

You can't use that if the prefix changes each time.  That is one simple example, but there are many other reason why not to do it.  

Now variable label is a different matter - that is not used in programming, it is purely for display.  That can be anything you like.  You can set a label by:

proc transpose data=temp out=analysis;
  format admitDate yymmdd10.;
  by patientId;
  var age systolic procedure1 procedure2 procedure3 procedure4 procedure5 diagnosis1 diagnosis2 diagnosis3 diagnosis4 diagnosis5;
  idlabel admitdate;
  id admitdate;
run;

Note, I haven't tested if that is valid syntax as you have not provided any test data (form of datastep) or required output.

malikah_sph
Calcite | Level 5
Thank you. I will try it and see if it works.
malikah_sph
Calcite | Level 5

I tried it. Its not exactly what I am looking for. I don't need the dates as row headers. I would like an array like how mentioned in my initial code which is how I need the data organized. I just need each admit date to format as a date and not as Number. How can I do that using the prefix statement as an array to separate the admit dates in the code below:

 

proc transpose data=temp
out=analysis
prefix=admitDate;
format admitDate yymmdd10.;
by patientId;
var age systolic procedure1 procedure2 procedure3 procedure4 procedure5 diagnosis1 diagnosis2 diagnosis3 diagnosis4 diagnosis5;
run;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Then please show what you do require.  Provide test data in the form of a datastep, and what the output should look like.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 6291 views
  • 0 likes
  • 2 in conversation