BookmarkSubscribeRSS Feed
marleeakerson
Calcite | Level 5

Hello, 

 

I am using this code:

data want;
infile "filepath"

delimiter = '|' 
MISSOVER 
DSD 
FIRSTOBS=2;
input 

ID $15.
Location_ID 9
Code 4
Date_Eff 8 
Date_Insert_Row 8
Date_Exp 8
Code_ID $9.
;

run; 

to infile data that looks like this:

ID|Location_ID|Code|Date_Eff|Date_Insert_Row|Date_Exp|Code_ID
100101160A |200010386|1|19920430|20200926|22991231|BR3209512
200001040A |200050045|1|19930630|20200926|22991231|AA8312693

 

but my output data looks like this:

marleeakerson_0-1603312554003.png

can someone help diagnosis this issue? it looks like the code isn't reading the delimiter properly? 

 

1 REPLY 1
Kurt_Bremser
Super User

Based on your data, your INPUT statement should look like this:

input 
  ID :$15.
  Location_ID :$9.
  Code :$1.
  Date_Eff :yymmdd8. 
  Date_Insert_Row :yymmdd8.
  Date_Exp :yymmdd8.
  Code_ID :$9.
;
format Date_Eff Date_Insert_Row Date_Exp :yymmdd10.;

Without the colon modifier, informats override the delimiters, because you then do what is called formatted input.

Dates should always be read as such, and codes as character

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 475 views
  • 0 likes
  • 2 in conversation