SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Jedrek369
Fluorite | Level 6

I have a list of values separated by space.

%let list = A B C;

I would like to create a single-column dataset.

Col1
A
B
C

 

Thanks in advance!

1 ACCEPTED SOLUTION
3 REPLIES 3
ballardw
Super User

You may want to consider specifying a length for Col1 variable based on your knowledge of the starting list. The default length using @Kurt_Bremser's solution will create a variable that is the length of the entire list. If you have many values that could mean that you have a variable of several hundred (or thousand) characters even though the longest value of interest is only one or two or some other number much smaller than thousands.

FreelanceReinh
Jade | Level 19

You can also let SAS determine the minimum required length of Col1:

data wide / view=wide;
retain c1-c%sysfunc(countw(&list,%str( )))
       ("%sysfunc(tranwrd(&list,%str( ),%str(" ")))");
run;

proc transpose data=wide out=want(drop=_:);
var c:;
run;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 3 replies
  • 2383 views
  • 1 like
  • 4 in conversation