BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tmtemples
Fluorite | Level 6

Hi!  I am trying to learn PROC REPORT and am having difficulty getting my dates to print in the correct order.  Here's my code:

 

PROC REPORT DATA = CAUTI_2016 NOWINDOWS ;
   COLUMN DATE LOCATION, (CAUTI DRAIN_DAYS) ;
   DEFINE DATE / GROUP ;
   DEFINE LOCATION / ACROSS ;
RUN ;

 

DATE is currently formatted as MONYY5.

 

My output looks like this:

DATE  CAUTI  DRAIN_DAYS

APR16        0                198

AUG16        2                222

FEB16         0                235

JAN16          0                178

 

How can I get it to print in the correct order?

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

The first question with date type data is "Is your value actually a SAS date valued variable or character?".

Proc contents or examine data set columns to confirm which.

You may need to set ORDER=Internal ind the define statement (if SAS Date value)

If the value is not a SAS date value then you will be stuck with character sort orders and won't work mostly. So you would want to add a SAS date valued variable and use that with appropriate format and order.

View solution in original post

2 REPLIES 2
ballardw
Super User

The first question with date type data is "Is your value actually a SAS date valued variable or character?".

Proc contents or examine data set columns to confirm which.

You may need to set ORDER=Internal ind the define statement (if SAS Date value)

If the value is not a SAS date value then you will be stuck with character sort orders and won't work mostly. So you would want to add a SAS date valued variable and use that with appropriate format and order.

tmtemples
Fluorite | Level 6

ORDER = INTERNAL  worked!

 

Thank you!

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