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

Hi ALL,

 

Am trying to learn Macros and got stuck in the very first code because its not giving any output/result..

 

%MACRO PRNT(ABC);
PROC PRINT DATA=&ABC;
RUN;
%MEND PRNT;

%PRNT(SASHELP.CLASS);

 

do i need to change the result/output setting from preferences?

how do i rectify this?

 

thanks,

Eram.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Eram
Fluorite | Level 6
Closed the SAS session, started a new SAS session and gave the same code, now log says, it couldn't find the variables
2208 %MACRO PRNT(ABC, V1, V2);
2209 PROC PRINT DATA=&ABC;
2210 VAR V1 V2;
2211 RUN;
2212 %MEND PRNT;

2213 %PRNT(CARS, MAKE, ORIGIN);
ERROR: Variable V1 not found.
ERROR: Variable V2 not found.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds



2214 %PRNT(WORK.CARS, MAKE, ORIGIN);
ERROR: Variable V1 not found.
ERROR: Variable V2 not found.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds



2215 %PRNT(WORK.CARS, Make, Origin);
ERROR: Variable V1 not found.
ERROR: Variable V2 not found.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

View solution in original post

9 REPLIES 9
Jagadishkatam
Amethyst | Level 16
Could you please show the log. Is there any error or warning or a note in log. it appears the macro code is correct and when I executed it generated the output in result window
Thanks,
Jag
Eram
Fluorite | Level 6

log doesnt say anything, just the typed macro is coming in log window with out any error, warning or note

Jagadishkatam
Amethyst | Level 16
may I know the sas version you are working
Thanks,
Jag
Eram
Fluorite | Level 6

SAS 9.3, but am working on VMware.

Eram
Fluorite | Level 6

Tried couple of times to run the macro using different conbinations but still no result but the log is showing only the Macro typed by me without any error or warning..

also the proc print step is coming in black color rather than blue- inside the the macro, is that ok?

 

2580 %MACRO PRNT_DT (ABC, V1, V2);
2581 PROC PRINT DATA=&ABC;
2582 VAR &V1 &V2;
2583 %MEND;

2584 %MACRO PRNT_DT = (CARS, MAKE, ORIGIN);


ERROR: Expected semicolon not found. The macro will not be compiled.
ERROR: A dummy macro will be compiled.


2585 %MACRO PRNT_DT (ABC, V1, V2);
2586 PROC PRINT DATA=&ABC;
2587 VAR &V1 &V2;
2588 RUN;
2589 %MEND;

2591 %PRNT_DT = (CARS, MAKE, ORIGIN);

 

2592 %MACRO PRNT_DT (ABC, V1, V2);
2593 PROC PRINT DATA=&ABC;
2594 VAR &V1 &V2;
2595 RUN;
2596 %MEND PRNT_DT;

2602 %PRNT;

 

2603 %MACRO PRNT(ABC);
2604 PROC PRINT DATA=&ABC;
2605 RUN;
2606 %MEND PRNT;
2607 %PRNT(CARS);
2608 %PRNT(CARS);
2609 %PRNT(SASHELP.CLASS);
2610 %PRNT(SASHELP.CLASS);


2611 %MACRO PRNT(ABC);
2612 PROC PRINT DATA=&ABC;
2613 RUN;
2614 %MEND PRNT;
2616 %PRNT(SASHELP.CLASS);

Eram
Fluorite | Level 6
Closed the SAS session, started a new SAS session and gave the same code, now log says, it couldn't find the variables
2208 %MACRO PRNT(ABC, V1, V2);
2209 PROC PRINT DATA=&ABC;
2210 VAR V1 V2;
2211 RUN;
2212 %MEND PRNT;

2213 %PRNT(CARS, MAKE, ORIGIN);
ERROR: Variable V1 not found.
ERROR: Variable V2 not found.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds



2214 %PRNT(WORK.CARS, MAKE, ORIGIN);
ERROR: Variable V1 not found.
ERROR: Variable V2 not found.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds



2215 %PRNT(WORK.CARS, Make, Origin);
ERROR: Variable V1 not found.
ERROR: Variable V2 not found.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

Eram
Fluorite | Level 6

Tried closing the session again and relogged in, Macro working fine now..

Reeza
Super User

@Eram that code is still incorrect. 

 

You're missing the & in front of the v1 and v2. 

Eram
Fluorite | Level 6
Kyle you pls type in the whole program for me?

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
  • 9 replies
  • 3325 views
  • 0 likes
  • 3 in conversation