BookmarkSubscribeRSS Feed
ToonKnight
Calcite | Level 5

Hi,

I'm generating a report using proc report to output data split by month. The issue that I'm currently having is sorting the months across in order. There are 2 attachments, one to represent the code and the other which conveys the output. For the output, my initial assumption is that this has something to do with the first row where there are no values. I have tried to remedy this but unfortunately to no avail.

Would really appreciate any help on the matter if possible.

Thanks




Max Bonus Output.JPGMonth Order.JPG
8 REPLIES 8
Reeza
Super User

Don't create Month as a text variable. Use the date value and format it in the report. Otherwise SAS will at best order it alphabetically.

Ksharp
Super User

Better don't use character Date .  and you padding blanks before them to get the order you want by proc format or override its value.

proc format;

value $x

'DEC2014'='    DEC2014' ;

run;

then add this format at proc report .

Xia Keshan

ToonKnight
Calcite | Level 5

I've managed to get my final output in the right order, but cannot format the 'date1' variable to get in the form mmmyy(i.e. DEC14 etc...). For instance, I've added the lines of code below which has managed to sort them in order but not in 'mmmyy' form. I've tried to format this in the proc report using 'Format = mmmyy5.' in the define statement however this returns an error 'variable date1 must use character variable'.

/*Data Build*/

date1 = put(UW_MTH, Julian5.);

put date1;

/*Proc report section*/

define Date1 / descending across ' - Month -'

Thanks

Reeza
Super User

Does something like this work:

*Instead use the raw variable and format it here:

/*Proc report section*/

define UW_MTH / descending across ' - Month -' format=monyy5.;

ToonKnight
Calcite | Level 5

Hi,

Sorry the question remains unanswered, not sure what happened, so please ignore the above.

I've tried using the raw variable in the proc report section it just outputs the same issue  as previous where the months are not in order.

The date1 variable is a character variable (with the month values now in numerical from). Would I need to convert character type to date type to eliminate the Sas error as stated above?

Thanks

Reeza
Super User

Post this in ODS Reporting and perhaps can help.  

Reeza
Super User

It works on this absolutely useless report:

proc report data=sashelp.stocks;

columns stock date;

define stock/group;

define date/across descending format=year4.;

run;

Make sure to post your full code and sample data, perhaps something else is the issue.

ToonKnight
Calcite | Level 5

Hi,

I've posted this original discussion in a new thread named 'Proc Report Month Order' under ODS and Base Reporting, with additional material.

If you could have a look then it would be greatly appreciated,

Thanks.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 8 replies
  • 2241 views
  • 6 likes
  • 3 in conversation