I'm reading in a fixed format text file. For the field "Invalid_date_free" (column 368), it can be populated or a null value. My question is -- can I read in the field with nulls allowed, in order to suppress those warning messages?
DATA free (drop=LastName dob PostalCode REC_TYPE db);
FORMAT SEQfree 9. HAS_free $1. free._FLAG $15.
BIRTHDATE DATETIME20.
DOB /*Spouse_DOB*/ Inactive_Date_free Effective_Date_free YYMMDDn8.
LINIT $2. LNAME LMATCH ACCT_free $20. PCODE $6.;
LENGTH DOB BIRTHDATE TRANSIT_free 8;
INFILE free MISSOVER TRUNCOVER LRECL=410 ;
INPUT @001 REC_TYPE $2. @ ;
if rec_type in ('1','9') then delete;
else if rec_type = '5'
then do;
INPUT @003 ClientNum_free $8.
@011 CifNumber 15.
@026 FirstName $23.
@049 MidName $23.
@072 LastName $23.
@095 DB $8. @;
if DB > 18000000 and DB < 21000000
then DOB = input(DB, YYMMDD8.);
else DOB = .;
INPUT @103 Gender $1.
@104 Spouse_FirstName $23.
@127 Spouse_MidName $23.
@150 Spouse_LastName $23.
/* @173 Spouse_DOB YYMMDD8.*/
@181 Spouse_Gender $1.
@182 Address1 $40.
@222 Address2 $40.
@262 City $35.
@297 StateProvince $2.
@299 PostalCode $6.
@305 Language $1.
@306 PhoneNumber $10.
@316 PolicyNum_free $8.
@324 LocationNum $8.
@332 BankKey $8.
@335 TRANSIT_free 5.
@340 ACCT_free $20.
@360 Effective_Date_free YYMMDD8.
@368 Inactive_Date_free YYMMDD8.
@376 Channel $2.
@378 BillDay 2.
@380 SUM_INS_free 9.
@389 SUM_INS_SPOUSE_free 9.
@398 PREM_free 6.
@404 Deceased $1.
@405 free.LetterType 1.
@406 INACTIVE_free $1.
;
SEQfree + 1;
if inactive_free. = 'N' then HAS_free. = 'Y';
if inactive_free. = 'N' then
free._flag = "ACTIVE" ;
else if inactive_Date_free >= "&bmth12"d then
free._flag = "INACTIVE_12m";
else free._flag = "INACTIVE_12_24m";
end;
else delete;
run;
It's easy. But remember, this now suppresses ALL messages about invalid data for that field. A simple change:
@368 Inactive_Date_free ?? YYMMDD8.
As long as you have valid SAS missing values there, no problem:
filename flatfile temp;
data _null_;
file flatfile;
put '20180709';
put ' ';
put '. ';
run;
data test;
infile flatfile;
input testdate yymmdd8.;
format testdate yymmddn8.;
run;
If you have anything else, I recommend reading into a string and then do a conditional conversion.
eg we have to read dates from DB/2, where a missing value will be a blank, and a "default" value will be 0001-01-01:
data want;
infile in;
input _mydate $10.;
if _mydate in ('0001-01-01',' ')
then mydate = .;
else mydate = input(_mydate,yymmdd10.);
format mydate yymmddd10.;
drop _mydate;
run;
It's easy. But remember, this now suppresses ALL messages about invalid data for that field. A simple change:
@368 Inactive_Date_free ?? YYMMDD8.
I'm ok with suppressing the messages. This is a long-running campaign that's pretty consistent across the board but the null values are due to a recent change in the requirements.
Thanks!
Since you have other "tripwires" (ie numeric data) after this field, even the "total warning suppressor" ?? will not prevent you from detecting a structural change in the file, so you should be good.
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!
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.