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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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