BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Bal23
Lapis Lazuli | Level 10

As we know, If you specify ORDER=DATA, the data are displayed in the same order as they occur in the input data set.  Other options for controlling order include ORDER=FORMATTED, which orders according to the formatted values, and ORDER=FREQUENCY, which orders by descending frequency count.

for me, my data is not what i expect, so the tables generate has "No" comes first beore "yes"

when i do copy and paste to the report, it is more time consuming

any advice how to change the order, so the "yes" always comes first before no, for each row, and column for each table?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Doc_Duke
Rhodochrosite | Level 12

One trick is to re-format the data.  You can put a space before the yes, so it is " yes" and leave the no as "no".  If th alignment causes you issues, you can use a non-printable character (you'll need to look at your collating sequence for that).

View solution in original post

5 REPLIES 5
sh0e
Obsidian | Level 7

Consider this code snippet

 

data report;
  set raw;
  if raw_value = 'Y' then display_value = 0;
  else display_value = 1;
  run;

proc format;
  value display
    0 = 'YES' 
   1 = 'NO';
    run;

proc report data = report missing;
  column <your-columns>;
  ...
  define display_value / order = internal format = display.;
 ...
  run;

 

Bal23
Lapis Lazuli | Level 10

thank you, but i am using proc freq, and with sas macro

i do not now how to change your code to proc freq, since i have so many tables to generate

Doc_Duke
Rhodochrosite | Level 12

One trick is to re-format the data.  You can put a space before the yes, so it is " yes" and leave the no as "no".  If th alignment causes you issues, you can use a non-printable character (you'll need to look at your collating sequence for that).

sh0e
Obsidian | Level 7

Sorry about that. I'm a PROC REPORT guy.

 

Here is a snippet using PROC FREQ instead.

 

proc freq data = report;
  format display_value display.;
  table display_value /
     missing list order=internal;
run;
Bal23
Lapis Lazuli | Level 10

thanks

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
  • 5 replies
  • 5663 views
  • 2 likes
  • 3 in conversation