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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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