Learning SAS? Welcome to the exclusive online community for all SAS learners.

Syntax question for name of a dataset

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Syntax question for name of a dataset

I got some errors and thought that you prob know how to resolve this one:

 

Below is the program I wrote, I was trying to use “%let  elg_data_mo” statement to let user define which dataset they want to pull,

then the program will go to directory “phi” and pull the corresponding dataset.

 

But the statement “set phi.&elg_data_mo.” Is causing errors, and I don’t know how to fix it.

 

Let me know if you know how.

Thanks!

 

 

 

libname phi     '/sasdata3/nta/projects/mcf_membership/production/data/phi';

 

%let  elg_data_mo = 'elgcap032017';

 

data test_data;

   set phi.&elg_data_mo.;    

run;

 


Accepted Solutions
Solution
‎04-27-2017 04:56 PM
Valued Guide
Posts: 634

Re: Syntax question for name of a dataset

[ Edited ]
Posted in reply to evayansitan

In the %LET statement you do not need, do not want, the quotes.  Unlike in the DATA step the macro language actually stores the quote marks and then they are included in your resolved text where they cause a problem.

 

%let dsn = abc;

data a;
set &dsn;
run;

 

View solution in original post


All Replies
Solution
‎04-27-2017 04:56 PM
Valued Guide
Posts: 634

Re: Syntax question for name of a dataset

[ Edited ]
Posted in reply to evayansitan

In the %LET statement you do not need, do not want, the quotes.  Unlike in the DATA step the macro language actually stores the quote marks and then they are included in your resolved text where they cause a problem.

 

%let dsn = abc;

data a;
set &dsn;
run;

 

New Contributor
Posts: 2

Re: Syntax question for name of a dataset

it worked!

Thank you so much!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 222 views
  • 0 likes
  • 2 in conversation