0
votes

I am using sas enterprise guide 8.3 to import a csv file into SAS.

I try to use import data wizard to do that; then copy the log of it to reuse it later(e.g. next week). the log looks like the following:

/*-------------------------------------------------
 code generated by a SAS task
  generated on Thursday, August 5,2021 at 9:59:13 PM
  By task: import data wizard
  Source File:
  d:\test\test.csv 
  Server: Local File System
  Output data: Work.temptable
  Server: [servername]
-------------------------------------------------------------------*/

Data: Work.temptable;
    Length:
     col1 
     col2
     
    Format:
    col1
    col2

    Informat:
    col
    col2
    
    Infile 'H:\Saswork\TD13012_[Server_name]\#LN_00032'
     
    Input
    col1
    col2;
   run;

My scenario is: I want to save the code above and rerun the code each week because there will be a new csv file each week, I need to import the new csv file each week. in the comment part, the source file is correct; but in the code part, it seems that infile points to a temp file 'H:\Saswork\TD13012_[Server_name]#LN_00032'. I wonder if this temp file always exists because I need to run the code each week. I try to replace the infile value with the correct location in the comment part(local folder, d:\test\test.csv ), there is an error message.

so how can I handle this infile? thanks!

1
I believe that the Import wizard in Enterprise Guide will let you select a file that the computer where EQ is running can access and upload it to the SAS server before submitting the code it generates. Is the CSV file you want to access already on the server where SAS is running? - Tom
@Tom, this CSV file is on my laptop where enterprise guide installed; and SAS server is in another machine. - fred wu
If you have the CSV file on your local computer you cannot re-run the code. You need a step to import the data to the server automatically. AFAIK the COPY Files task cannot be automated. The temp file is a reference to SAS copying the file to the server as part of this process to read it in. - Reeza

1 Answers

1
votes

If the file is on the server where SAS is running then just run the data step to read it. If the file is on the server where EG is running then you will first need to add a step in your process to upload the file to the SAS server before your SAS code can see the file. EG should have "copy files" task you can use

Note that the Import wizard might be modifying the file in the upload process, so make sure your new code works with the original file.

PS You can write a much better data step than what Enterprise Guide generates. For example most variables do not need to have either an INFORMAT or a FORMAT attached to them. SAS already knows how to read and write both character strings and numbers without any need to give it special instructions.