Hi all,
I am trying to create a zero dataset with DATASTEP, which contains only attrib information or we can assign/modify attributes of variables.
Below is the code:
data x;
attrib
x label="X" length=$25.;
stop;
run;
But I'm getting below warning
15274 data x;
15275 attrib
15276 x label="X" length=$25.;
15277 stop;
15278 run;
NOTE: Variable x is uninitialized.
NOTE: The data set WORK.X has 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.00 seconds
Please anyone can help me in fixing this.
Regards,
Anv_SAS
This is just a NOTE, not a WARNING.
If you want to prevent it, assign a value to x before the stop statement.
Hi @Anv_SAS,
Put the assignment statement (or CALL MISSING, etc.) after the STOP statement. Then it will not be executed, i.e., you really don't assign a value. Nevertheless, the note in the log will no longer appear because the compiler sees an assignment.
Edit: Alternatively you can use a RETAIN statement with an initial value if you prefer a declarative statement.
The stop statement prevents any writing of values to the dataset, so it does not matter what you assign to the variable.
Adding the variables to an ARRAY will prevent the message. But you need a separate array for the numeric and character variables.
You can also use the CALL MISSING() function.
110 data x; 111 attrib x label="X" length=$25; 112 array _ _character_; 113 stop; 114 run; NOTE: The data set WORK.X has 0 observations and 1 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.03 seconds 115 116 data x; 117 attrib x label="X" length=$25; 118 stop; 119 call missing(of _all_); 120 run; NOTE: The data set WORK.X has 0 observations and 1 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.01 seconds
PS There is no need to include a decimal point when specifying a length. Lengths can only be integers.
Then give X a initial value(missing value).
data x;
attrib x label="X" length=$25.;
x=' ';
stop;
run;
OR Try PROC SQL
proc sql;
create table x (
x char(25) label='X'
);
quit;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.