When I open a SAS dataset, there is a numeric variable (var1) which shows character values like C, M when opened
Also,
There is a code that queries that dataset and that numeric variable var1 as below
data test;
set myds;
if var1 = .C then newvar=10;
run;
Proc contents show that there is no format applied on that column. That variable var1 is num 8.
What does this .C mean and why are character variables shown in a numeric field?
In addition to the normal missing value SAS supports 27 special missing values which you represent in code as ._, .A, .b, up to .z.
You can use them to make different categories of missing values. For example if you had a survey question you might use one to mean question not asked, another to mean respondent refused to answer, another to mean respondent doesn't know the answer, etc.
Please see the code below. SAS interprets .C, .A and such as missing values. However, they are missing as PROC FREQ reveals.
data test;
a=.A;output;
a=.;output;
a=.B;output;
run;
data test2;
set test;
if a=.B then dummy=1;
else dummy=0;
run;
proc freq data=test;
run;
Thanks for the quick response.
Is this a feature? why will we need Character missing values?
It is pretty confusing
In addition to the normal missing value SAS supports 27 special missing values which you represent in code as ._, .A, .b, up to .z.
You can use them to make different categories of missing values. For example if you had a survey question you might use one to mean question not asked, another to mean respondent refused to answer, another to mean respondent doesn't know the answer, etc.
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.