09-14-2014 07:49 AM
proc chart data=&dsn;
title "Chart for &dat";
call execute('%rept('||date||','||'var1,reptdata)'); /* here is use of pipe that I need to know */
09-14-2014 08:41 AM
|| 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
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.
09-14-2014 08:54 AM
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.
09-14-2014 10:39 AM
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