BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rhapsody
Calcite | Level 5

I have a string called number_name='1','18','19';. What I want in the end is for that number variable to end up in the name of my final dataset (prediction_&number_name_conv.) . All of this is summarized in the example below.

 

 

 

%let number_name='1','18','19';



data _null_;
call symput('number_name_conv', trim(left(input("&number_name.", comma10.))));
run;



data prediction_&number_name_conv.;

set raw_data;

run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
SwissC
Obsidian | Level 7

 

using

call symput('number_name_conv', compress("&number_name", "kn"));

could than give you a dataset called prediction_11819

or 

data _null_;
  a="number_name";
  b=tranwrd(a, "'", "");
  c=tranwrd(b, ",", "_");
  call symput('number_name_conv', compress(c));
run;

would give a final dataset name of prediction_1_18_19

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

What do you want the data set name to be in the end?

rhapsody
Calcite | Level 5
data prediction_&number_name_conv.;

set raw_data;

run;
SwissC
Obsidian | Level 7

 

using

call symput('number_name_conv', compress("&number_name", "kn"));

could than give you a dataset called prediction_11819

or 

data _null_;
  a="number_name";
  b=tranwrd(a, "'", "");
  c=tranwrd(b, ",", "_");
  call symput('number_name_conv', compress(c));
run;

would give a final dataset name of prediction_1_18_19

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