DATA Step, Macro, Functions and more

File Import vs Data Step Import

Reply
Super Contributor
Posts: 621

File Import vs Data Step Import

When I imported the .csv file from my desktop via File-> Import Data from SAS EG I can see the data set created as expected. However when I place the same file in server and I used a Data step to import the file  I end up with missing records for all the variables. SAS code which I used here is a copy of the log from the File-> Import Data. Only thing which I changed in the coding part is the file location in Infile statement. There is no error in the log file as well.

 

Appreciate if someone help me to get rid of this issue.

Super User
Posts: 9,611

Re: File Import vs Data Step Import

EG converts the input file to a standardized format, copies the result to a file in the WORK location, and then runs a data step to read the converted data. Because of the conversion, this data step code won't fit your original data.

Two possible remedies:

- use proc import on the server, and then copy the data step (created and run by proc import) from the log

- write the data step yourself according to the documentation of the csv file; this option is preferred

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
SAS Super FREQ
Posts: 806

Re: File Import vs Data Step Import

Enterprise Guide converts the file to some other format and uses a different delimiter "7F"x between the data values.

 

Please check your code, the DLM= option on the INFILE statement propably looks like DLM='7F'x. Change it to the correct delimiter, something like DLM=",".

 

Note that you can also import CSV files that are located on the server

One page 4 of the import wizard you can select "Generalize import step to run outside of Enterprise Guide". Using thsi option will not create an intermediate file and just runs.

Super Contributor
Posts: 621

Re: File Import vs Data Step Import

Posted in reply to Bruno_SAS

Still I facing the same issue after updating the DLM option to  DLM=",". Could you please help me understand what is still causing an issue?

Super User
Posts: 9,611

Re: File Import vs Data Step Import

Don't expect that a single change will fix your issue on the first try. Use the tool that sits between your ears.

Read the log.

See if the delimiter fits at all (your text file might have a different one).

See if all column specifications match the data in your infile.

If you still end up puzzled, post code&log, and attach a sample of your file.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 4 replies
  • 172 views
  • 2 likes
  • 3 in conversation