BookmarkSubscribeRSS Feed
NagendraBS
Fluorite | Level 6
I have a variable with values
NA - a1 b1 c1 a2 b2 c2 a3 b3

I need a new dataset with new variable sorted and old variable should not be sorted as below
NA - a1 b1 c1 a2 b2 c2 a3 b3
NA1 - a1 a2 a3 b1 b2 b3 c1 c2

Thanks in advance.
2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Post test data in the form of a datastep!!!

 

What is NA, is it one variable, a set of variables?  If it is one variable, why is it one variable, a variable is to hold one piece of information, hence coding against a variable with multiple pieces of information will be difficult, whereas if each their own its very simple.

data want;
  na1="a1";
  na2="b1";
  na3="c1";
  na4="a2";
  original_na=catx(" ",of na:);
  call sortc(of na:);
run;

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 lock in 2025 pricing—just $495!

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