The SAS Output Delivery System and reporting techniques

ordering dates in PROC REPORT

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

ordering dates in PROC REPORT

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!


Accepted Solutions
Solution
‎12-19-2016 01:09 PM
Super User
Posts: 11,343

Re: ordering dates in PROC REPORT

Posted in reply to tmtemples

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


All Replies
Solution
‎12-19-2016 01:09 PM
Super User
Posts: 11,343

Re: ordering dates in PROC REPORT

Posted in reply to tmtemples

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.

Occasional Contributor
Posts: 17

Re: ordering dates in PROC REPORT

ORDER = INTERNAL  worked!

 

Thank you!

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 218 views
  • 0 likes
  • 2 in conversation