Desktop productivity for business analysts and programmers

Prompt Help

Reply
N/A
Posts: 0

Prompt Help

Hi there

I am having problems using prompts in EG. I want to specify an if statement to do one of two things depending on a prompt. The prompt will be either "MPANlist" or "Portfolio".

Plesae see code below. When I change the first line from "Portfolio" to "MPANlist" sas still ruuns the second if statement (which is for the prompt value"Portfolio")

Please Help!


%let Process = "Portfolio";

%macro Choose_Process;

%if $Process = "MPANList" %then %do;
PROC SQL;
CREATE TABLE WORK.Voltage_ID AS
SELECT t1.MPANCORE2,
t1.LLF,
t2.Voltage_ID,
t1.Dist_ID2
FROM MPAN_IMPORT_DIST_ID_FORMAT AS t1, WORK.TX920_LOSSES_LOOKUP_FORMAT AS t2
WHERE (t1.LLF = t2.LLF AND t1.Dist_ID2 = t2.DIST_ID);
quit;
%end;

%else %if &Process = "Portfolio" %then %do;
PROC SQL;
CREATE TABLE WORK.Voltage_ID AS
SELECT t1.MPANCORE,
t1.Dist_ID2,
t1.LLF2,
t2.Voltage_ID as TEST
FROM WORK.CALC_DIST_ID_FORMAT AS t1, WORK.TX920_LOSSES_LOOKUP_FORMAT AS t2
WHERE (t1.LLF2 = t2.LLF AND t1.Dist_ID2 = t2.DIST_ID);
QUIT;
%end;

%mend Choose_Process;

%Choose_Process
Run;
PROC Star
Posts: 1,146

Re: Prompt Help

I think your code is just about right.

A couple of changes:

First of all, in your first %if statement change $Process to &Process

Second, macro variables are different from SAS character variables. Usually, you don't put them in quotes. I'm not sure what your prompts will be like, but it is likely that the following statements will work better:

%let Process = Portfolio;
%if &Process = MPANList %then %do;
%else %if &Process = Portfolio %then %do;

Good luck!
Tom
N/A
Posts: 0

Re: Prompt Help

Thanks for your help! I cannot believe I made a mistake as simple as that in the program! Amateur mistake to make!

The program runs just fine for the prompt Portfolio, but when I replace the prompt with MPANlist the following error is thrown up:

"The open data operation failed. The following data error occurred.
[error] File Work.Voltage.ID.Data does not exist."

Any ideas?
PROC Star
Posts: 1,146

Re: Prompt Help

It's hard to know what this problem could be. In your post, the dataset name is Work.Voltage.ID.Data

Are there periods in it, or underscores?
Ask a Question
Discussion stats
  • 3 replies
  • 135 views
  • 0 likes
  • 2 in conversation