BookmarkSubscribeRSS Feed
marleeakerson
Calcite | Level 5

I am running a relatively simple piece of code (pasted below): 

 

data
X
Y ;
set have;
if &StartDate <= Birth_Date then output=X;
if &Date20 <= Birth_Date <= &Date12 then output=Y;
run;

 

But when I run it i get this error:

 

NOTE: Variable X is uninitialized.
NOTE: Variable Y is uninitialized.

 

Can anyone explain why this is happening? X and Y are tables i am trying to create, not variables. 

 

Thank you!

1 REPLY 1
Reeza
Super User

The syntax is wrong, the = sign is not required and instead reads as a variable assignment, ie SAS is interpreting this as "add a variable output with the value of X/Y", not use the OUTPUT statement functionality.

 

Remove the = sign.

 

 

data    X     Y ;
set have;
if &StartDate <= Birth_Date then output X;
if &Date20 <= Birth_Date <= &Date12 then output Y;

run;

 

FYI - please post your code in a code block, don't italicize it. The code block helps maintain formatting, legibility and doesn't add extra HTML characters.


@marleeakerson wrote:

I am running a relatively simple piece of code (pasted below): 

 

data
X
Y ;
set have;
if &StartDate <= Birth_Date then output=X;
if &Date20 <= Birth_Date <= &Date12 then output=Y;
run;

 

But when I run it i get this error:

 

NOTE: Variable X is uninitialized.
NOTE: Variable Y is uninitialized.

 

Can anyone explain why this is happening? X and Y are tables i am trying to create, not variables. 

 

Thank you!


 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 521 views
  • 2 likes
  • 2 in conversation