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

I'm attempting to order a proc report output for an outlook email and having issues order by values of a formatted column. I've tried sorting the data with a proc sort before my proc report statement but it does seem to have any affect on the sort order. I've also tried to use the 'order order=internal' option with my define statement of my formatted column but that results in my formatted column to lose its formatting and does not sort the data.

 

data weight;  
   infile datalines missover;
   input IDnumber $ Week1; 
   datalines; 
1 15 
2 22 
3 6
4 17
5 19
6 3
7 29
;



proc format;
   value cfmt 
	low-10='red'
      10-20 ='yellow'
      20-high='green'
     	;
   value dot 
	low-high='^{style [vjust=top fontsize=10pt]^{unicode 2B24}}';
run;


proc sort data=weight out=weight1; by Week1; run;


ods escapechar="^";

	options emailsys=smtp;
	options emailauthprotocol=none;
	options emailhost= ;
	/*options emailport=25;*/
	options emailID = ;
	options emailpw = ;



	filename temp email
	to = 
/*	cc = */
/*	bcc = */
	subject="test"
	type="text/html"
	from =  ;


	title;
	ODS html body=temp; 


	PROC REPORT DATA=weight1 headline headskip split='*' 
		style(column header summary) = {font_size=2 background=white font_face="Arial" vjust=c}; 

	column	Week1 IDNUMBER;

	define Week1/ style(column)=[foreground=cfmt. vjust=c]  format=dot. ' ';
	DEFINE IDNUMBER /  group style(column)=[vjust=c] center 'ID' width=12;
	
	run;

	ods _all_ close;

 

 

 

And the output as follows:

 

Capture.PNG

 

My desired output would be the IDs ordered ascending by the raw value of the weight column.

 

When changing my define statement of week1 to the following:

	define Week1/ order order=internal style(column)=[foreground=cfmt. vjust=c]  format=dot. ' ';

 

I get a the following output that I can't interpret what is being done for:

Capture.PNG

 

 

Any insight into any alternative approaches or what I may have wrong would be greatly appreciated.

 

1 ACCEPTED SOLUTION

Accepted Solutions
unison
Lapis Lazuli | Level 10

order=data (to match the current data order)?

Is this what you want?

 

PROC REPORT DATA=weight1 headline headskip split='*' 
	style(column header summary) = {font_size=2 background=white font_face="Arial" vjust=c}; 

column	Week1 IDNUMBER;

define Week1/ style(column)=[foreground=cfmt. vjust=c]  format=dot. ' ';
DEFINE IDNUMBER / order=data  group style(column)=[vjust=c] center 'ID' width=12;

run;

 -unison

-unison

View solution in original post

1 REPLY 1
unison
Lapis Lazuli | Level 10

order=data (to match the current data order)?

Is this what you want?

 

PROC REPORT DATA=weight1 headline headskip split='*' 
	style(column header summary) = {font_size=2 background=white font_face="Arial" vjust=c}; 

column	Week1 IDNUMBER;

define Week1/ style(column)=[foreground=cfmt. vjust=c]  format=dot. ' ';
DEFINE IDNUMBER / order=data  group style(column)=[vjust=c] center 'ID' width=12;

run;

 -unison

-unison

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 696 views
  • 0 likes
  • 2 in conversation