I need to create an empty dataset but without the uninitialized issue that shows in the log.
I have tried the following
data SHELL;
format FirstName LastName $200.;
stop;
run;
and this
data SHELL;
length FirstName LastName $200;
stop;
run;
Unfortunately I am still getting uninitialized in my log.
I would like to try to avoid this as I would be doing this for about +- 30 variables every time.
data SHELL;
length FirstName LastName $200;
FirstName = "";
LastName = "";
run;
Help with this would be appreciated.
data SHELL;
length FirstName LastName $ 200;
call missing(of _ALL_);
stop;
run;
Bart
The log message about uninitialized variables is expected in the case where you have uninitialized variables, and is not a bad thing in this case in my opinion. So I don't have a problem with the log message, and I wouldn't spend time and effort to fix it (if a fix is possible).
data SHELL;
length FirstName LastName $ 200;
call missing(of _ALL_);
stop;
run;
Bart
Hi @Anonymity,
In practice, I would also use the DATA step approach with CALL MISSING because of the familiar syntax. Other options include:
proc sql;
create table SHELL
(FirstName char(200), LastName char(200));
quit;
options varinitchk=nonote;
and reset the option to note (or whatever the previous setting was) afterwards.data SHELL;
array x[*] $200 FirstName LastName;
stop;
run;
You can use CALL MISSING(of _all_) to initialize the variables.
You can also use an array definition as SAS doesn't issue the note for variables that are in arrays. But that requires that you need to know if you have both numeric and character variables since all variables in a single array must be of the same type.
PS Use the LENGTH statement to define the type/length of the variables. Use a FORMAT statement only if you actually need to attach a format to the variables. Your example variables do not need formats attached to them.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: