BookmarkSubscribeRSS Feed
SAS_New_User1
Obsidian | Level 7

I want to import a file into SAS Dataset. The file is in (.DAT) format. The file does not have delimiter.

However I do know the position of the data.

 

eg. Data in the file is as below 

D12302020.....745639200.89USD.......ACCOUNTNULL12354596895...CHN.........

 

Position information provided is as below 

Field                        Data Length            Data Type

Record Type                  1                          Char

Date                               8                          Date

Code                              6                          Number

Amount                          11                        Decimal

Country                           3                        Char

 

 

The data should be in output in this way 

Col1         Col2           Col3            Col4              Col5

D           12302020        7           45639200.89    USD

 

So based on the start and end position of the string I should be able to separate the columns, i.e. Col1 position(1), Col2 position (2-9), Col3 position(10-15) etc. however I am unable to do import the data into the table. 

1 REPLY 1
Reeza
Super User
See example 3.8 here
You have what's known as a fixed width or formatted input file.
You need to specify more details and the location of each to be read.

https://online.stat.psu.edu/stat480/lesson/3/3.3

See the Column Input examples here:
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n13ejk9swz5vrbn0z34iazfrp0wp.htm

and Formatted Input examples here:
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p0f9yk6pd4znukn1rlw6hzkg1url.htm

For 5 fields writing the code is pretty straightforward exercise.