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

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? 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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? 


 

 

View solution in original post

3 REPLIES 3
Reeza
Super User

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? 


 

 

SPR
Quartz | Level 8 SPR
Quartz | Level 8
I moved ODS output PearsonCorr=Pearson; inside the proc CORR and the program works fine without quit; Thanks.
RichardDeVen
Barite | Level 11

Regarding PROC boundaries and ODS OUTPUT statement, the same concept is in play with other statements such as TITLE and FOOTNOTE.

 

SAS Innovate 2025: Register Now

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!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1071 views
  • 3 likes
  • 3 in conversation