BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DucatiJong
Calcite | Level 5

Hi,

 

The example below error-ed out. I believe I need to resolve my macro var before the datastep but not sure how. Could someone please advise how I can run this correctly.

 

%macro Test ( InputDS = L1DWP.CUSTOMER_DIM_&LAST_MONTH_YYYYMM.

OutptDS = CUSTOMER_DIM_&LAST_MONTH_YYYYMM.);

data &OutptDS.;

set &InputDS. (obs=10);

 

run;

%mend;

 

%Test;

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Your example is missing a comma, but not sure if that will solve your problem:

 

%macro Test ( InputDS = L1DWP.CUSTOMER_DIM_&LAST_MONTH_YYYYMM. ,
OutptDS = CUSTOMER_DIM_&LAST_MONTH_YYYYMM.);
data &OutptDS.;
set &InputDS. (obs=10);
 
run;
%mend;
 
%Test;

View solution in original post

7 REPLIES 7
SASKiwi
PROC Star

Your example is missing a comma, but not sure if that will solve your problem:

 

%macro Test ( InputDS = L1DWP.CUSTOMER_DIM_&LAST_MONTH_YYYYMM. ,
OutptDS = CUSTOMER_DIM_&LAST_MONTH_YYYYMM.);
data &OutptDS.;
set &InputDS. (obs=10);
 
run;
%mend;
 
%Test;
DucatiJong
Calcite | Level 5

Haha - trap for the young player!

PaigeMiller
Diamond | Level 26

Execute the command OPTIONS MPRINT; before you run the code. Then, show us the SASLOG so we can see the error message, by clicking the {i} icon and pasting the SASLOG into the window that appears.

 

--
Paige Miller
DucatiJong
Calcite | Level 5

1 %_eg_hidenotesandsource;

MPRINT(_EG_HIDENOTESANDSOURCE): options nonotes;

MPRINT(_EG_HIDENOTESANDSOURCE): options nosource;

MPRINT(_EG_RESTORENOTESANDSOURCE): options NOTES;

MPRINT(_EG_RESTORENOTESANDSOURCE): options SOURCE;

5 %_eg_hidenotesandsource;

MPRINT(_EG_HIDENOTESANDSOURCE): options nonotes;

MPRINT(_EG_HIDENOTESANDSOURCE): options nosource;

MPRINT(_EG_RESTORENOTESANDSOURCE): options NOTES;

MPRINT(_EG_RESTORENOTESANDSOURCE): options SOURCE;

28

29

30 options mprint;

31 %macro Test ( InputDS = L1DWP.CUSTOMER_DIM_&LAST_MONTH_YYYYMM.

32 OutptDS = CUSTOMER_DIM_&LAST_MONTH_YYYYMM.);

33

34 data &OutptDS.;

35 set &InputDS. (obs=10);

36 run;

37

38 %mend;

39

40 %Test;

WARNING: Apparent symbolic reference OUTPTDS not resolved.

NOTE: Line generated by the invoked macro "TEST".

40 data &OutptDS.;

_

22

200

MPRINT(TEST): data &OutptDS.;

MPRINT(TEST): set L1DWP.CUSTOMER_DIM_201808 OutptDS = CUSTOMER_DIM_201808 (obs=10);

MPRINT(TEST): run;

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, /, ;, _DATA_, _LAST_, _NULL_.

ERROR 200-322: The symbol is not recognized and will be ignored.

NOTE: Compression was disabled for data set WORK.DATA22 because compression overhead would increase the size of the data set.

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.DATA22 may be incomplete. When this step was stopped there were 0 observations and 0 variables.

NOTE: DATA statement used (Total process time):

real time 0.00 seconds

user cpu time 0.00 seconds

system cpu time 0.00 seconds

memory 285.65k

OS Memory 19028.00k

Timestamp 10/09/2018 01:13:27 PM

Step Count 95 Switch Count 48

 

NOTE: Line generated by the macro variable "INPUTDS".

40 L1DWP.CUSTOMER_DIM_&LAST_MONTH_YYYYMM. OutptDS = CUSTOMER_DIM_&LAST_MONTH_YYYYMM.

_

22

76

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, -, :, ;, CUROBS, END, INDSNAME, KEY,

KEYRESET, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.

2 The SAS System 10:36 Tuesday, October 9, 2018

ERROR 76-322: Syntax error, statement will be ignored.

41

42 %_eg_hidenotesandsource;

MPRINT(_EG_HIDENOTESANDSOURCE): options nonotes;

MPRINT(_EG_HIDENOTESANDSOURCE): options nosource;

MPRINT(_EG_RESTORENOTESANDSOURCE): options NOTES;

MPRINT(_EG_RESTORENOTESANDSOURCE): options SOURCE;

54

55

56 %_eg_hidenotesandsource;

MPRINT(_EG_HIDENOTESANDSOURCE): options nonotes;

MPRINT(_EG_HIDENOTESANDSOURCE): options nosource;

MPRINT(_EG_RESTORENOTESANDSOURCE): options NOTES;

MPRINT(_EG_RESTORENOTESANDSOURCE): options SOURCE;

59

PaigeMiller
Diamond | Level 26

As stated by @SASKiwi, your code is missing a comma. Please fix that, then run the code again and paste the SASLOG into the {i} window. 

--
Paige Miller
DucatiJong
Calcite | Level 5

Thanks. All good now.

ChrisNZ
Tourmaline | Level 20

That's why I always align code. You would have seen the issue right away if you were used to writing:

 

%macro Test ( InputDS = L1DWP.CUSTOMER_DIM_&LAST_MONTH_YYYYMM.

            , OutptDS = CUSTOMER_DIM_&LAST_MONTH_YYYYMM.      );

  data &OutptDS.;

    set &InputDS. (obs=10);

  run;

%mend;

 

%Test;

 

Same for proc sql: commas first. 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1522 views
  • 0 likes
  • 4 in conversation