BookmarkSubscribeRSS Feed
keen_sas
Quartz | Level 8

Hi All,

  We generally create new variables using assignment statement. When the specified variable is not present in the data step we get an uniniitalized note in the SAS log. But the requirement is to generate an ERROR in the log if the specified variable is not present while creating new variable using assignment statement. Any ideas on this.

data want;
 set sashelp.class;
 new=gender;
run ;

NOTE: Variable gender is uninitialized.
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.WANT has 19 observations and 7 variables.
NOTE: Compressing data set WORK.WANT increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
1 REPLY 1
FreelanceReinh
Jade | Level 19

Hi @keen_sas,

 

Have you tried the VARINITCHK system option?

options varinitchk=error;

Your DATA step would then result in:

ERROR: Variable gender is uninitialized.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.WANT may be incomplete.  When this step was stopped there were 0 observations and 7 variables.
NOTE: DATA statement used (Total process time):
...
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
  • 1 reply
  • 662 views
  • 2 likes
  • 2 in conversation