BookmarkSubscribeRSS Feed
raj143
Calcite | Level 5

i created two variables like var1 and var2.

%let var1=10;

%let var2=raju;

how to create dataset from these two variables with titled dataset name as "age_name" .???

thanks inadvance.....

5 REPLIES 5
ballardw
Super User

@raj143 wrote:

i created two variables like var1 and var2.

%let var1=10;

%let var2=raju;

how to create dataset from these two variables with titled dataset name as "age_name" .???

thanks inadvance.....


Why must a macro be involved? IF you are actually creating the macro variables with %let statements you are just adding work.

 

Data age_name;

   var1=10;

   var2 ='raju';

run;

would do it.

If the macro variable come from another process then YOU must know what type of value the data step variable would have to be and the result would look like:

 

Data age_name;

   var1 = &var1.;

   var2 = "&var2.";

run;

 

note that for macro text to resolve properly the values must be in double quotes, "   ", not single quotes, '   '.

 

Astounding
PROC Star

If you are asking how to create a data set named 10_raju, you should modify your plan.  That's not a legal data set name.

Reeza
Super User

There's not enough information in your initial post but I'm going to make a wild guess that you're looking for this:

 

https://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/

 


@raj143 wrote:

i created two variables like var1 and var2.

%let var1=10;

%let var2=raju;

how to create dataset from these two variables with titled dataset name as "age_name" .???

thanks inadvance.....


 

mnjtrana
Pyrite | Level 9
Hi @raj143,

As others pointed out, the problem is not much clear.

Can you provide more info.

Thanks,
Manjeet

Cheers from India!

Manjeet
Patrick
Opal | Level 21

@raj143 wrote:

i created two variables like var1 and var2.

%let var1=10;

%let var2=raju;

how to create dataset from these two variables with titled dataset name as "age_name" .???

thanks inadvance.....


@raj143 This is not twitter here so you've got actually ample space to formulate your problem and to even provide sample data....

 

Guessing what you're asking for:

%let var1=10;
%let var2=raju;

data &var2._&var1.;
  set sashelp.class;
run;

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 5 replies
  • 1221 views
  • 4 likes
  • 6 in conversation