%macro rept(dat,a,dsn);
proc chart data=&dsn;
title "Chart for &dat";
where(date="&dat");
vbar &a;
run;
%mend rept;
data _null_;
set dates;
call execute('%rept('||date||','||'var1,reptdata)'); /* here is use of pipe that I need to know */
run;
|| is the concatenation operator in SAS. In Excel you would use &.
Call execute(<code to be executed>) allows SAS to place a section of code into the program flow to be executed immediately after the data step concludes. In this case the code to be executed is a macro rept which is intended to draw a vbar chart on var1 for a given date drawing data from the reptdata table. The data _null_ step is intended to provide the date parameter from a table called dates. Lets say the date, being numeric, has the unformatted value 12345 (I have no idea what date that is). Then the code inserted into the program flow should be
%rept(12345,var1,reptdata)
To get this result the data _null_ step has to join some constant text values: %rept( and then later ,var1,reptdata) with the date value 12345 taken from the dates table in the middle. The expression could be simplified as
call execute('%rept(' ||date|| ', var1, reptdata)'); /* spaces added for clarity */
since apparently for this example var1 from reptdata is always used when table dates is used as the source of date data.
Richard
As Stated in
to generate a macro invocation whose parameter is the value of the variable resolved by the DATA step to a macro text expression or a SAS statement.
If you like, you could use the cats() function instead, which will give you commas instead of the double pipes.
A bit more readable if you ask me
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.
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.