DATA Step, Macro, Functions and more

Unexpected Errors

Accepted Solution Solved
Reply
Contributor
Posts: 53
Accepted Solution

Unexpected Errors

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)Smiley SadColumn).

      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


Accepted Solutions
Solution
‎06-06-2013 10:53 AM
Super User
Posts: 5,518

Re: Unexpected Errors

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


All Replies
Super Contributor
Posts: 334

Re: Unexpected Errors

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

Contributor
Posts: 53

Re: Unexpected Errors

It is a library / folder.

SM

Super Contributor
Posts: 334

Re: Unexpected Errors

What does the proc contents of your dataset report?

Frequent Contributor
Posts: 127

Re: Unexpected Errors

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

Solution
‎06-06-2013 10:53 AM
Super User
Posts: 5,518

Re: Unexpected Errors

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 " ");


Frequent Contributor
Posts: 127

Re: Unexpected Errors

Posted in reply to Astounding

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

New Contributor
Posts: 3

Re: Unexpected Errors

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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