BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi I have data set like this

data var;
input Variables:$20.;
cards;
aa
bb
cc
dd
ee
ff
;;
run;

and would like to convert to something like this

LIST1 LIST2 LIST3 LIST4 LIST5 LIST6
aa,bb bb,aa
aa,bb,cc aa,cc,bb bb,aa,cc bb,cc,aa cc,aa,bb cc,bb,aa
then 4
then 5
and so on
..
..
..


Then use these list in an array to shorten the code below

data test;
set test;
if new_var in ("aa bb","bb aa") then number='01';
if new_var in ("aa bb cc","aa cc bb","bb aa cc","bb cc aa","cc aa bb","cc bb aa") then number='02';
and so on.

Thank you Message was edited by: coi
1 REPLY 1
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Explore using SAS PROC TRANSPOSE to take your vertical observations and create a horizontal perspective.

Though I'm not totally clear about the origin of new_var, you can use an ARRAY declaration and reference a variable prefix, such as LIST: -- possibly to build a new CHARACTER type variable with a string-concatenation of your LIST1-LISTn variables, possibly, to use in your IF/THEN logic.

Scott Barry
SBBWorks, Inc.
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
  • 1 reply
  • 876 views
  • 0 likes
  • 2 in conversation