Desktop productivity for business analysts and programmers

Change the output name of a table based on a processmonth parameter

Reply
New Contributor
Posts: 4

Change the output name of a table based on a processmonth parameter

How can I "actively" change the output name of a Table in Sas Enterprise Guide using a &processmonth parameter, using a query builder?
For example if I'm running data for 2015-12 and i want for the final table to have a standard name prefix such as: "SAS_PM_BEHAVIOR_&processmonth"
Can this be done with Query Builder? I tried but it disn't work.
Help please to all you SAS gurus out there!
Grand Advisor
Posts: 17,464

Re: Change the output name of a table based on a processmonth parameter

I believe so. There's a place in Query Builder to specify the output table name. There you can place the code you have above.
Respected Advisor
Posts: 3,840

Re: Change the output name of a table based on a processmonth parameter

[ Edited ]

What @Reeza proposes works in my EG version (7.11) only if changing the table name via Options/Change Button as shown below.

 

Capture.PNG

 

If I just enter the name into the "Output name" field then it get's quoted as name literal and generates code like

CREATE TABLE WORK.'test&test'n AS 

 

Only after the rename via "options" drop-down I'm getting the table name generated without quoting.

CREATE TABLE WORK.test&test AS 

New Contributor
Posts: 4

Re: Change the output name of a table based on a processmonth parameter

First of all thanks for answering so quickly. 

I just tried this but I get the following error:

 

SAS_parameter error.JPG

Any clues?

Respected Advisor
Posts: 3,840

Re: Change the output name of a table based on a processmonth parameter

It works in my 7.11 EG version.

New Contributor
Posts: 4

Re: Change the output name of a table based on a processmonth parameter

Do I have to set up a special condition under the Prompt Manager option or Tools>Options?

Do you think it might be due to the EG version that I have which is earlier than yours?

 

--

DLP

Respected Advisor
Posts: 3,840

Re: Change the output name of a table based on a processmonth parameter

I've run first the following code for my test.

%let test=myTest;
data test;
  set sashelp.class;
run;

Then I've used the query builder as alredy posted.

 

If this doesn't work for you then I must assume it's caused by an earlier version of SAS EG.

 

Grand Advisor
Posts: 17,464

Re: Change the output name of a table based on a processmonth parameter

What version of EG do you have? I would also considering a quick call to Tech Support or a repost to EG group so that some of the EG users can help.
New Contributor
Posts: 4

Re: Change the output name of a table based on a processmonth parameter

I'm using version 5.1. Could that be the reason it does not work?
I will try calling Tech Support.  Any other help on this is deeply appreciated.  
Thanks

Community Manager
Posts: 2,707

Re: Change the output name of a table based on a processmonth parameter

The solution that @Patrick supplied is creative, but it's a bit of a trick that might be working by accident, and not by design.

 

As far as I know, there isn't an official method to substitute in a macro value for the output data name in the Query Builder.  My suggested workaround would be:

 

- Create the query to output to a known, static name (ex: work.currentmonth).

- Link a subsequent program node that renames/copies that data set to the name you want, using the macro variable that you supply.  You could do this with DATA step or PROC COPY or PROC DATASETS.

 

Chris

Ask a Question
Discussion stats
  • 9 replies
  • 468 views
  • 0 likes
  • 4 in conversation