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

How can I control the output vaiable sort order when I don't have a Class statement.  I want them to be alphabetical.

 

Tammy

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

You can make your own list of names in the alphabetical order and put them in a macro variable.

 

data class;
   set sashelp.class;
   retain a10 a1 a3 a011 1;
   run;
proc contents data=class(keep=_numeric_) noprint out=names(keep=name);
   run;
proc sql noprint;
   select nliteral(name) into :alphanames separated by ' '
      from names;
   quit;
   run;
%put NOTE: &=alphanames;

You may want to added ORDER=IGNORECASE to PROC CONTENTS to change the order as follows.  PROC CONTENTS "automatically" handles the numeric suffice properly.

 

36         %put NOTE: &=alphanames;
NOTE: ALPHANAMES=a1 a3 a10 a011 Age Height Weight

 

View solution in original post

7 REPLIES 7
ballardw
Super User

I think you'll need to provide a bit more detail. What "them" do you want in alphabetic order? The variables, the statististics, in rows or columns?

 

You may need to provide an example data set and what you want for output for the given example.

TMiles
Quartz | Level 8

The Variable list

JediApprentice
Pyrite | Level 9

The var statement specifies the analysis variables and the order in which they are displayed in the results. You could put them in alphabetical order like the example below.

 

PROC MEANS DATA=people;
  CLASS personID;
  VAR age height sex weight;
  OUTPUT OUT=people2 MEAN= ;
RUN;
TMiles
Quartz | Level 8

Yes, but I have 605 variables so I am using _numeric_ ... so the output is in the internal variable order.  I know I can do this with options on the class statement, but I don't have a class variable.

proc means data=out1.&promo._modelvars n mean median mode std min max skew kurt;
  var _numeric_;
run;

means.JPG

ballardw
Super User

Send the data to an output dataset and sort by variable name or possibly label as makes more sense.

data_null__
Jade | Level 19

You can make your own list of names in the alphabetical order and put them in a macro variable.

 

data class;
   set sashelp.class;
   retain a10 a1 a3 a011 1;
   run;
proc contents data=class(keep=_numeric_) noprint out=names(keep=name);
   run;
proc sql noprint;
   select nliteral(name) into :alphanames separated by ' '
      from names;
   quit;
   run;
%put NOTE: &=alphanames;

You may want to added ORDER=IGNORECASE to PROC CONTENTS to change the order as follows.  PROC CONTENTS "automatically" handles the numeric suffice properly.

 

36         %put NOTE: &=alphanames;
NOTE: ALPHANAMES=a1 a3 a10 a011 Age Height Weight

 

TMiles
Quartz | Level 8

perfect solution -I should have thought of this -guess I was trying to make it harder than it needed to be  -Thank you

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 7 replies
  • 3370 views
  • 2 likes
  • 4 in conversation