BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sfmeier
Obsidian | Level 7

Hi experts,

I am filtering on some character variables

      /* Import der Matchingdaten zw. KontoID/System und fdb-Nummer */

      data &workbib..i_gls_fdb2;

            set kris_lls.D487_&stichmonat._GLS_VB (Keep =   syst_source iden_source_system fdb_nr ref_fdb_nr ref_fdb_rolle gls_lfs_vb_nr

                                                                                    referenz_nr ogid_risk_point isin LFS_nr);

            if (not fdb_nr = . or not ref_fdb_nr = 0) and ( not iden_source_system = "" or not gls_lfs_vb_nr = "");

      run;

However I am getting the following Notes (the IF-line is NR. 20):

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

      20:55   20:85  

NOTE: Invalid numeric data, iden_source_system='DE000LB0AEB3_T' , at line 20 column 55.

NOTE: Invalid numeric data, gls_lfs_vb_nr='DE000LB0AEB3' , at line 20 column 85.

syst_source=ARENA_P iden_source_system=DE000LB0AEB3_T ogid_risk_point=24542733 fdb_nr=. lfs_nr=. ref_fdb_rolle=. ref_fdb_nr=.

gls_lfs_vb_nr=DE000LB0AEB3 isin=  referenz_nr=0 lfs=FEHLT _ERROR_=1 _N_=2

So why does SAS convert my Character values to numeric values? Is it because the first line in the table contains (coincidentally) just numbers? How can I prevent that from happening?

Thx a lot,

Stefan

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Putting "not" in front of a logical comparison can be very tricky and may not be interpreted the way you suspect.  I would recommend changing along these lines:

if (fdb_nr ne . or ref_fdb_nr ne 0) and (iden_source_system ne " " or gls_lfs_vb_nr ne " ");


View solution in original post

7 REPLIES 7
esjackso
Quartz | Level 8

Is the dataset being set a sas dataset or is it using a connection to an external data source? IE is kris_lls a folder or connection?

EJ

sfmeier
Obsidian | Level 7

It is a library / folder.

SM

esjackso
Quartz | Level 8

What does the proc contents of your dataset report?

Florent
Quartz | Level 8

Hi,

What if you replace your IF statement by the following ?

if (not missing(fdb_nr) or ref_fdb_nr ne 0) and (not missing(iden_source_system) or not missing(gls_lfs_vb_nr));

Kind regards,

Florent

Astounding
PROC Star

Putting "not" in front of a logical comparison can be very tricky and may not be interpreted the way you suspect.  I would recommend changing along these lines:

if (fdb_nr ne . or ref_fdb_nr ne 0) and (iden_source_system ne " " or gls_lfs_vb_nr ne " ");


Florent
Quartz | Level 8

Indeed, and I strongly encourage the use of the missing function since it allows not having to care for datatype Smiley Wink

Brit
Calcite | Level 5

Also the missing function will work as expected on special missing values, such as .D, .N, etc.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1633 views
  • 7 likes
  • 5 in conversation