BookmarkSubscribeRSS Feed
hyracer86
Calcite | Level 5

Hi

 

 I'm using the following code to import a text file from a server to SAS, but the file contains some "Non-Printable ASCII" characters like "NUL", "SOH", "SUB" etc like the image bellow, I think thats the reason why I'm losing some records and getting others truncated during the import process.

 

 Is there any specific way to import this kind of files?

 

Thanks!

 

Sample File (click to open the image):

 

Posicional.png

  

Code:

 

data A;

infile "/server/sas/lib/file.txt" lrecl = 4096 truncover;

input

@1 COLLUMN_A 9.
@10 COLLUMN_B $CHAR10.
@20 COLLUMN_C $CHAR20.
@40 COLLUMN_D $CHAR3.
@43 COLLUMN_E $CHAR1.
@44 COLLUMN_F $CHAR1.
@45 COLLUMN_G $CHAR1.
@46 COLLUMN_H $CHAR18.
@64 COLLUMN_I $CHAR6.
@70 COLLUMN_ETC $CHAR5.;

run;

 

1 REPLY 1
Patrick
Opal | Level 21

@hyracer86

The record layout in your screenshot and the how you set the pointers in your data step don't align. 

Where did you get the start positions, types and lengths for your field from. Is that based on some record description/data dictionary?

Do you have additional information for this source file?

 

Ideally: Instead of a picture attach a text file here with a few actual records in it.

If you have to download the file first from a server then make sure that there is no character conversion happening (i.e. use ftp in binary mode).

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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