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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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