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
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 " ");
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
It is a library / folder.
SM
What does the proc contents of your dataset report?
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
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 " ");
Indeed, and I strongly encourage the use of the missing function since it allows not having to care for datatype
Also the missing function will work as expected on special missing values, such as .D, .N, etc.
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!
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.