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

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

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
  • 877 views
  • 0 likes
  • 3 in conversation