BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi all,

i'm still very new with SAS EG and SAS Macro.
At first i thought it was gonna be no problem to learn it, since i've got some experience in programming and databases.
But surely i was totally wrong!
Hopefully can learn a lot from more seasoned users here

I created some code as below:

/*---BEGIN CODE--- */
%MACRO CRT_TBL_GRW(officeID);
%LET TABLE_NAME='WORK._' || %put(&officeID);
%PUT &TABLE_NAME;

PROC SQL OUTOBS=5;
CREATE TABLE &TABLE_NAME AS SELECT DISTINCT TOP5GROWTH_OF_OS_CA_INC.AccountId FORMAT=$20.,
TOP5GROWTH_OF_OS_CA_INC.AccountName FORMAT=$20.,
TOP5GROWTH_OF_OS_CA_INC.CustomerId FORMAT=$20.,
TOP5GROWTH_OF_OS_CA_INC.ProductCategory FORMAT=$50.,
TOP5GROWTH_OF_OS_CA_INC.FunctionalGroup FORMAT=$40.,
TOP5GROWTH_OF_OS_CA_INC.OfficeId FORMAT=11.,
TOP5GROWTH_OF_OS_CA_INC.CurrentBalance_IDR FORMAT=COMMA17.1,
TOP5GROWTH_OF_OS_CA_INC.Calculation1
FROM WORK.TOP5GROWTH_OF_OS_CA_INC AS TOP5GROWTH_OF_OS_CA_INC
WHERE TOP5GROWTH_OF_OS_CA_INC.ProductCategory = "GIRO" AND TOP5GROWTH_OF_OS_CA_INC.OfficeId = &officeID
GROUP BY TOP5GROWTH_OF_OS_CA_INC.OfficeId
ORDER BY TOP5GROWTH_OF_OS_CA_INC.OfficeId, TOP5GROWTH_OF_OS_CA_INC.Calculation1 DESCENDING;
QUIT;

%MEND;

%CRT_TBL_GRW(2384);
%CRT_TBL_GRW(2023);

/* ---END CODE---*/

I want to pass parameter through variable and create several tables, but i couldn't manage to run this code properly.

The log says:
NOTE: Line generated by the macro variable "TABLE_NAME".
44 'WORK._' ||
__
22
ERROR 202-322: The option or parameter is not recognized and will be ignored.

ERROR 22-322: Syntax error, expecting one of the following: (, AS, LIKE.


Please help, i need some enlightment

thank you

Best Regards,
M. Djojo
4 REPLIES 4
Adrian_Mc
Calcite | Level 5
You shouldn't need to use the %put() function around the &officeID macro variable.
Try it without it. If there's still an issue you could use the %sysfunc(left(&officeId)) function to left align the office id.

Hope that helps...
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Constructing macro variables is not like a DATA step approach - no concatenation (vertical bars) and no quote-marks.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

using macro variables site:sas.com

SAS DOC reference:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002047074.htm
Cynthia_sas
SAS Super FREQ
Hi:
As other folks have explained, macro programming and macro variable concatenation is NOT like DATA step programming or DATA step variable concatenation. This is a good introduction to the concepts of macro variable referencing and writing SAS Macro programs.
http://www2.sas.com/proceedings/sugi28/056-28.pdf

cynthia
deleted_user
Not applicable
Hi all,

The macro runs perfectly now, many thanks for your feedbacks.
I will definitely take a while before getting familiar with SAS codes.

Thank you

Best Regards,
M. Djojo

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1705 views
  • 0 likes
  • 4 in conversation