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;
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
What do you want the data set name to be in the end?
data prediction_&number_name_conv.;
set raw_data;
run;
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
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.