Help using Base SAS procedures

Not Combing rows and Ordering them Proc Report

Accepted Solution Solved
Reply
Super Contributor
Posts: 477
Accepted Solution

Not Combing rows and Ordering them Proc Report

[ Edited ]

I have a dataset with two "Section 2" rows.  When I run the below it merges the two columns together.  I am trying to sort the rows manually by using a format then display the rows without merging them. 

 

proc sql;
insert into FacultyProfileFall
(colPreOrdering2, colPreOrdering, _c2_, _c3_, _c4_, _c5_, _c6_, _c7_)
values (20, 'Section 2', 0, 0, 0, 0, 0, 0);
quit;

 

title1 'FacultyProfileFall Output';
proc report data=FacultyProfileFall;
column colPreOrdering2 _c2_ _c3_ _c4_ _c5_ _c6_ _c7_;
define _c2_ / format=comma9. '2011-12';
define _c3_ / format=comma9. '2012-13';
define _c4_ / format=comma9. '2013-14';

define _c5_ / format=comma9. '2014-15';
define _c6_ / format=comma9. '2015-16';
define _c7_ / format=comma9. '2016-17';
define colPreOrdering2 / group order = internal left '';
format colPreOrdering2 rankFormatValue.;
run;


Accepted Solutions
Solution
‎07-05-2017 08:54 AM
SAS Super FREQ
Posts: 8,740

Re: Not Combing rows and Ordering them Proc Report

[ Edited ]

Hi:
Take a look here:
http://support.sas.com/documentation/cdl/en/proc/70377/HTML/default/viewer.htm#p0wy1vqwvz43uhn1g77eb...

At the statement that the ORDER= option on the DEFINE statement ONLY will be used for ORDER, GROUP or ACROSS items. That option will be ignored for DISPLAY items and you should be seeing the sorted order of the rows by default (if all your variables are DISPLAY).

The specific sentence on the doc page for ORDER= says
"ORDER=DATA | FORMATTED | FREQ | INTERNAL
orders the values of a group, order, or across variable according to the specified order..."

cynthia

View solution in original post


All Replies
SAS Super FREQ
Posts: 8,740

Re: Not Combing rows and Ordering them Proc Report

[ Edited ]

Hi:
Well, the default behavior of using GROUP for an item on the report row is to collapse or summarize all the numeric variables for that group. So if you do NOT want GROUP as the usage, why not try ORDER as the usage.

Consider the difference in the 2 outputs below. You didn't provide your format, so it is impossible to understand what you are trying to do with the format and I might not have understood what you mean by having 2 section 2 rows, since you did not provide data, but I think the sample code and image shows what the difference is between GROUP and ORDER.
cynthia

 

grp_vs_order.png

Super Contributor
Posts: 477

Re: Not Combing rows and Ordering them Proc Report

[ Edited ]

I was able to sort the data and then order by data.

 

define colPreOrdering2 / display order=data left '';

Solution
‎07-05-2017 08:54 AM
SAS Super FREQ
Posts: 8,740

Re: Not Combing rows and Ordering them Proc Report

[ Edited ]

Hi:
Take a look here:
http://support.sas.com/documentation/cdl/en/proc/70377/HTML/default/viewer.htm#p0wy1vqwvz43uhn1g77eb...

At the statement that the ORDER= option on the DEFINE statement ONLY will be used for ORDER, GROUP or ACROSS items. That option will be ignored for DISPLAY items and you should be seeing the sorted order of the rows by default (if all your variables are DISPLAY).

The specific sentence on the doc page for ORDER= says
"ORDER=DATA | FORMATTED | FREQ | INTERNAL
orders the values of a group, order, or across variable according to the specified order..."

cynthia

☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 138 views
  • 2 likes
  • 2 in conversation