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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15
data SHELL;
    length FirstName LastName $ 200;
    call missing(of _ALL_);
    stop;
run;

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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).

--
Paige Miller
yabwon
Onyx | Level 15
data SHELL;
    length FirstName LastName $ 200;
    call missing(of _ALL_);
    stop;
run;

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



FreelanceReinh
Jade | Level 19

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
    proc sql;
    create table SHELL
    (FirstName char(200), LastName char(200));
    quit;
  • Temporarily suppress the unwanted note in the log (and then use a DATA step without the need for CALL MISSING):
    options varinitchk=nonote;
    and reset the option to note (or whatever the previous setting was) afterwards.
  • Use one or more arrays:
    data SHELL;
    array x[*] $200 FirstName LastName;
    stop;
    run;
Tom
Super User Tom
Super User

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 10045 views
  • 7 likes
  • 5 in conversation