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.
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): ...
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.