This simple program does not produce Pearson dataset:
data a;
a=1; b=3; output;
a=4; b=5; output;
run;
proc SQL noprint; select MAX(A) into :a trimmed from a; %put &=a;
ODS output PearsonCorr=Pearson;
proc CORR data=a;
var a;
with b;
run;
WARNING: Output 'PearsonCorr' was not created. Make sure that the output object name, label, or path is spelled correctly. Also,
verify that the appropriate procedure options are used to produce the requested output object. For example, verify that
the NOPRINT option is not used.
The reason for this is absence of quit; in proc SQL code.
Using
proc SQL noprint; select MAX(A) into :a trimmed from a; quit; %put &=a;
produces the expected output:
NOTE: The data set WORK.PEARSON has 1 observations and 3 variables.
I've noticed that some seasoned programmers do not put quit; in this type proc SQL code. This trick works fine in most cases but not every time. Or may be I'm wrong?
Boundaries, where code blocks start/stop, are defined by QUIT, RUN, DATA and PROC. ODS is not a boundary statement.
The issue in this case is you do not explicitly terminate the prior procedure so the ODS OUTPUT statement is mapped to the SQL procedure not the PROC CORR.
If you move the ODS OUTPUT to after the PROC it's also fine because the PROC acts as a boundary. Basically, its an order of operations thing - you need to ensure the boundary is set before your ODS statements.
@SPR wrote:
This simple program does not produce Pearson dataset:
data a;
a=1; b=3; output;
a=4; b=5; output;
run;proc SQL noprint; select MAX(A) into :a trimmed from a; %put &=a;
ODS output PearsonCorr=Pearson;
proc CORR data=a;
var a;
with b;
run;WARNING: Output 'PearsonCorr' was not created. Make sure that the output object name, label, or path is spelled correctly. Also,
verify that the appropriate procedure options are used to produce the requested output object. For example, verify that
the NOPRINT option is not used.
The reason for this is absence of quit; in proc SQL code.
Using
proc SQL noprint; select MAX(A) into :a trimmed from a; quit; %put &=a;
produces the expected output:
NOTE: The data set WORK.PEARSON has 1 observations and 3 variables.
I've noticed that some seasoned programmers do not put quit; in this type proc SQL code. This trick works fine in most cases but not every time. Or may be I'm wrong?
Boundaries, where code blocks start/stop, are defined by QUIT, RUN, DATA and PROC. ODS is not a boundary statement.
The issue in this case is you do not explicitly terminate the prior procedure so the ODS OUTPUT statement is mapped to the SQL procedure not the PROC CORR.
If you move the ODS OUTPUT to after the PROC it's also fine because the PROC acts as a boundary. Basically, its an order of operations thing - you need to ensure the boundary is set before your ODS statements.
@SPR wrote:
This simple program does not produce Pearson dataset:
data a;
a=1; b=3; output;
a=4; b=5; output;
run;proc SQL noprint; select MAX(A) into :a trimmed from a; %put &=a;
ODS output PearsonCorr=Pearson;
proc CORR data=a;
var a;
with b;
run;WARNING: Output 'PearsonCorr' was not created. Make sure that the output object name, label, or path is spelled correctly. Also,
verify that the appropriate procedure options are used to produce the requested output object. For example, verify that
the NOPRINT option is not used.
The reason for this is absence of quit; in proc SQL code.
Using
proc SQL noprint; select MAX(A) into :a trimmed from a; quit; %put &=a;
produces the expected output:
NOTE: The data set WORK.PEARSON has 1 observations and 3 variables.
I've noticed that some seasoned programmers do not put quit; in this type proc SQL code. This trick works fine in most cases but not every time. Or may be I'm wrong?
Regarding PROC boundaries and ODS OUTPUT statement, the same concept is in play with other statements such as TITLE and FOOTNOTE.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.