Reputation: 25
I've used this forum to gather information on creating and using prompts in SAS EG tasks and queries. However, I can't seem to transfer my own syntax from Base SAS, incorporate/reference prompts/macros I've created, and get it to work.
Currently, everytime I reference a prompt in my own program (rather than one generated by point-click selections in SAS EG) the log tells me SAS can't resolve the macro reference.
How can I transfer my own program into SAS EG and then integrate the prompts?
Example code I used to develop test data set:
data work.testscores;
input Gender $ 1-6 SATScore 8-11 IDNumber 13-20;
datalines;
Male 1170 61469897
Female 1090 33081197
Male 1240 68137597
Female 1490 9589297
Male 1200 93891897
Female 1080 26212897
Male 1050 8945097
Female 1200 51799397
Male 1600 39196697
;
run;
/created Genders prompt in the prompt manager using gender variable/
PROC SQL;
CREATE table WORK.testscores2 as
SELECT &Genders, SATScore
FROM WORK.TESTSCORES
;
QUIT;
Log:
102 PROC SQL;
103 CREATE TABLE WORK.TESTSCORES2 AS
104 SELECT &Genders
WARNING: Apparent symbolic reference GENDERS not resolved.
104 SELECT &Genders
_
22
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
a numeric constant, a datetime constant, a missing value, BTRIM, INPUT, PUT,
SUBSTRING, USER.
105 FROM WORK.TESTSCORES;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
106 QUIT;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Thanks,A
Upvotes: 0
Views: 1749
Reputation: 1763
Judging by the comments of the topic starter, it looks like there is some misunderstanding how prompts in EG work. It's not a tool for assigning value to some macrovariable BEFORE running your program. 'Prompt' implies that the program prompts you to enter the value DURING the program running. But for that, you have to assign your prompt to coressponding program, so that when you run this particular program SAS would envoke this particular prompt. For that: right click on the task -> Properties -> Prompts -> Add
.
Upvotes: 1
Reputation: 87
I dont understand what you want to achieve by your code. Do you want select just male or female SAT-scores based on the value of the macro variable you set in the prompt?
proc sql;
create table work.testscores2 as
select gender, satscore
from work.testscores
where gender = &genders.;
/* Where the value of &genders is either 'Male' or 'Female' */
quit;
Upvotes: 1
Reputation: 63424
To use a macro variable created in a prompt, you need to check the box "Use prompt value throughout project".
Upvotes: 0