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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

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