BookmarkSubscribeRSS Feed
Filipvdr
Pyrite | Level 9

hi,

at my client i have to put .K (which corresponds with not known), .V , .D ... possible in a numeric field. As it begins with a . SAS accepts it.

var&i = .K

But i'm getting this errors... any help?

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).

      17:17    17:77    17:137   17:197   19:17    19:77    19:137   19:197   21:17    21:77    21:137   21:197   23:17    23:77    23:137   23:197   25:17    25:77

      25:137   25:197   27:17    27:77    27:137   27:197   29:17    29:77    29:137   29:197   31:17    31:77    31:137   31:197

5 REPLIES 5
manojinpec
Obsidian | Level 7

Please post with code and some example what you want to achieve

Filipvdr
Pyrite | Level 9

underneath my datastep, the result is ok

For example:

AEENMTH is numeric, and has as value K after running the datastep. But I think i'm getting some "Notes" because of that:

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).

      17:17    17:77    17:137   17:197   19:17    19:77    19:137   19:197   21:17    21:77    21:137   21:197   23:17    23:77    23:137   23:197   25:17    25:77

      25:137   25:197   27:17    27:77    27:137   27:197   29:17    29:77    29:137   29:197   31:17    31:77    31:137   31:197

Is there a way to rewrite the code, to not get this note?

Datastep:

data current.AE;

set AE_temp;

if (AEACN = '' and _AEACN = 1) then AEACN = .K ;

else if (AEACN = '' and _AEACN = 2) then AEACN = .V ;

else if (AEACN = '' and _AEACN = 3) then AEACN = .D ;

else if (AEACN = '' and _AEACN = 4) then AEACN = .A ;

drop _AEACN ;

if (AEENDT = '' and _AEENDT = 1) then AEENDT = .K ;

else if (AEENDT = '' and _AEENDT = 2) then AEENDT = .V ;

else if (AEENDT = '' and _AEENDT = 3) then AEENDT = .D ;

else if (AEENDT = '' and _AEENDT = 4) then AEENDT = .A ;

drop _AEENDT ;

if (AEENMTH = '' and _AEENMTH = 1) then AEENMTH = .K ;

else if (AEENMTH = '' and _AEENMTH = 2) then AEENMTH = .V ;

else if (AEENMTH = '' and _AEENMTH = 3) then AEENMTH = .D ;

else if (AEENMTH = '' and _AEENMTH = 4) then AEENMTH = .A ;

drop _AEENMTH ;

if (AEREL = '' and _AEREL = 1) then AEREL = .K ;

else if (AEREL = '' and _AEREL = 2) then AEREL = .V ;

else if (AEREL = '' and _AEREL = 3) then AEREL = .D ;

else if (AEREL = '' and _AEREL = 4) then AEREL = .A ;

drop _AEREL ;

if (AEREL2 = '' and _AEREL2 = 1) then AEREL2 = .K ;

else if (AEREL2 = '' and _AEREL2 = 2) then AEREL2 = .V ;

else if (AEREL2 = '' and _AEREL2 = 3) then AEREL2 = .D ;

else if (AEREL2 = '' and _AEREL2 = 4) then AEREL2 = .A ;

drop _AEREL2 ;

if (AESEV = '' and _AESEV = 1) then AESEV = .K ;

else if (AESEV = '' and _AESEV = 2) then AESEV = .V ;

else if (AESEV = '' and _AESEV = 3) then AESEV = .D ;

else if (AESEV = '' and _AESEV = 4) then AESEV = .A ;

drop _AESEV ;

if (AESTDT = '' and _AESTDT = 1) then AESTDT = .K ;

else if (AESTDT = '' and _AESTDT = 2) then AESTDT = .V ;

else if (AESTDT = '' and _AESTDT = 3) then AESTDT = .D ;

else if (AESTDT = '' and _AESTDT = 4) then AESTDT = .A ;

drop _AESTDT ;

if (AESTMTH = '' and _AESTMTH = 1) then AESTMTH = .K ;

else if (AESTMTH = '' and _AESTMTH = 2) then AESTMTH = .V ;

else if (AESTMTH = '' and _AESTMTH = 3) then AESTMTH = .D ;

else if (AESTMTH = '' and _AESTMTH = 4) then AESTMTH = .A ;

drop _AESTMTH ;

run;

Keith
Obsidian | Level 7

very simple, = ' ' refers to a character missing value.  You're applying it to a numeric variable, so it is converting the character missing value to a numeric missing value.

You can either change ' ' to . which is the default missing numeric value, or use missing(varname) which applies to both character and numeric variables (and will also pick up special missing numeric values such as .K)

Filipvdr
Pyrite | Level 9

thanks.. did not focused on that part.. though it could be possible that I don't know if the variable is numeric or character...

Keith
Obsidian | Level 7

If you're not sure of the variable type then use the MISSING function, although if you're assigning a new value then you obviously need to know which type to use!

It's not covered in the scope of you question, but your code can be simplified using either of the 2 methods below.  This saves checking for the missing value each time.

if missing(AEACN) then do;

         if _AEACN = 1 then AEACN = .K;         

  else if _AEACN = 2 then AEACN = .V;

  else if _AEACN = 3 then AEACN = .D;

  else if _AEACN = 4 then AEACN = .A;

end;

drop  _AEACN;

if missing(AEACN) then do;

  select (_AEACN);

   when (1) AEACN = .K;

   when (2) AEACN = .V;

   when (3) AEACN = .D;

   when (4) AEACN = .A;

  otherwise end;

end;

drop _AEACN;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 2791 views
  • 0 likes
  • 3 in conversation