Import a csv file and then export a sas dataset

Reply
Contributor
Posts: 24

Import a csv file and then export a sas dataset

[ Edited ]

Hi,

 

I'm trying to import a csv file and then export a sas dataset as on output but I'm running into issues. Can anyone let me know where I'm going wrong? My code logic is as follows:

 

Import:

Proc Import out=xyz

datafile='c:\User\Folder\File_Abc.csv'

DBMS =csv replace;

run;

 

SAS Dataset export

Libname out 'c:\user\Desktop';

data out.test;

set xyz;

run;

 

I'm receiving an error saying "set is not allowed in the data statement". 

 

Can anyone let me know how I export the sas dataset here? Thank you. 

 

 

Contributor
Posts: 31

Re: Import a csv file and then export a sas dataset

Posted in reply to SteelersPitts

You need to close your quotation marks for both times you use it. Also, you had an extra semicolon in the proc import statement.

 

Proc Import out=xyz
   datafile='c:\User\Folder\File_Abc.csv'
   DBMS =csv replace;
run;

 


Libname out 'c:\user\Desktop';

data out.test;
set xyz;
run;
Contributor
Posts: 24

Re: Import a csv file and then export a sas dataset

Posted in reply to Urban_Science

I apologize for the missing quotes and extra semi-colon in the post. However, the code has proper quotes and semi-colon but it still does throw up errors.

Contributor
Posts: 31

Re: Import a csv file and then export a sas dataset

Posted in reply to SteelersPitts
Without seeing the errors, my guess is that the paths are wrong. C:\Users\<User Name>\
But that could be an editing mistake when posting.
Contributor
Posts: 31

Re: Import a csv file and then export a sas dataset

Posted in reply to Urban_Science
I didn't see that you edited your post. Nevermind with the path. My new guess is that you might have forgotten a semicolon after data out.test
Super User
Posts: 24,018

Re: Import a csv file and then export a sas dataset

Posted in reply to SteelersPitts

Post the full log from the code you're running.

 


@SteelersPitts wrote:

Hi,

 

I'm trying to import a csv file and then export a sas dataset as on output but I'm running into issues. Can anyone let me know where I'm going wrong? My code logic is as follows:

 

Import:

Proc Import out=xyz

datafile='c:\User\Folder\File_Abc.csv'

DBMS =csv replace;

run;

 

SAS Dataset export

Libname out 'c:\user\Desktop';

data out.test;

set xyz;

run;

 

I'm receiving an error saying "set is not allowed in the data statement". 

 

Can anyone let me know how I export the sas dataset here? Thank you. 

 

 


 

Contributor
Posts: 24

Re: Import a csv file and then export a sas dataset

My bad! Code is working fine now. There was a missing semi-colon. Thanks everyone. 

Ask a Question
Discussion stats
  • 6 replies
  • 77 views
  • 1 like
  • 3 in conversation