BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rogerjdeangelis
Barite | Level 11
This will put the variables in alphabetic order

%symdel odrvars vardim odr; * just in case it exists; data want; * get meta data; if _n_ =0 then do; %let rc=%sysfunc(dosubl(' data _null_; set sashelp.class(obs=1); array num _numeric_; array chr _character_; length vars $4096; do i=1 to dim(num); vars=catx(",",vars,quote(vname(num[i]))); end; do i=1 to dim(chr); vars=catx(",",vars,quote(vname(chr[i]))); end; call symputx("odrvars",vars); call symputx("vardim",put(dim(num)+dim(chr),5.)); run;quit; data _null_; length odr $4096; array varall[&vardim] $32 (&odrvars); call sortc(of varall(*)); odr=catx(" ",of varall[*]); call symputx("odr",odr); run;quit; ')); end; retain &odr; set sashelp.class; run;quit; run;quit; Up to 40 obs WORK.WANT total obs=19 Obs AGE HEIGHT NAME SEX WEIGHT 1 14 69.0 Alfred M 112.5 2 13 56.5 Alice F 84.0 3 13 65.3 Barbara F 98.0 4 14 62.8 Carol F 102.5 5 14 63.5 Henry M 102.5

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
  • 15 replies
  • 2998 views
  • 4 likes
  • 6 in conversation