dataset creation using macro variables

Reply
Occasional Contributor
Posts: 7

dataset creation using macro variables

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.....

Super User
Posts: 13,583

Re: dataset creation using macro variables


@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, '   '.

 

Super User
Posts: 6,785

Re: dataset creation using macro variables

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.

Super User
Posts: 23,776

Re: dataset creation using macro variables

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.....


 

Frequent Contributor
Posts: 79

Re: dataset creation using macro variables

Hi @raj143,

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

Can you provide more info.

Thanks,
Manjeet

Cheers from India!

Manjeet
Respected Advisor
Posts: 4,737

Re: dataset creation using macro variables

[ Edited ]

@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;

 

Ask a Question
Discussion stats
  • 5 replies
  • 148 views
  • 4 likes
  • 6 in conversation