Help using Base SAS procedures

How to import a .csv file in a table format in SAS

Reply
Contributor
Posts: 23

How to import a .csv file in a table format in SAS

Hi , I am using SAS Studio, have already uploaded csv file which are my data files.How do I convert the csv file to data file.I do not find the data import wizard in the SAS on Demand for Academics.

Thank you and Best regards,

Sudipta

Attachment
Super User
Posts: 3,101

Re: How to import a .csv file in a table format in SAS

You could try PROC IMPORT:

PROC IMPORT OUT = my_csv

          FILE = "c:\my_csv.csv"

          DBMS = CSV

          REPLACE;

RUN;

SAS Super FREQ
Posts: 8,740

Re: How to import a .csv file in a table format in SAS

HI: Basically, PROC IMPORT is the correct approach. However, remember that SAS Studio does not read a C: drive location if you are using SAS Studio with the University Edition or with SAS OnDemand for Academics. For the SAS University Edition, you will need to put the CSV file in your shared folder location and your FILE= option will be something like: FILE='/folders/myfolders/my_csv.csv'. But for SAS OnDemand for Academics, when you signed up for the account, you were given a directory path, so in this instance, you would need to upload the file to your space on the server and then your FILE= option would be something like: FILE='~/xxxxxxxxx/my_csv.csv';  (where ~/xxxxxxxxxx/ is the location you find in your OnDemand control center for your directory path).

cynthia

Contributor
Posts: 23

Re: How to import a .csv file in a table format in SAS

Thank you both, I tired out the same procedure.Got the following output.

I wanted the name of the variables to be left blank.Here it is taking the first value as variable names.

sas-table2.png

Super User
Posts: 3,101

Re: How to import a .csv file in a table format in SAS

Try adding this statement to your program before the RUN statement:

GETNAMES = NO;

Contributor
Posts: 23

Re: How to import a .csv file in a table format in SAS

Thank you both, my problem got resolved. If I need to insert names to the variable, how do I go about it?

Super User
Posts: 3,101

Re: How to import a .csv file in a table format in SAS

Check out the RENAME statement in the documentation.

Contributor
Posts: 23

Re: How to import a .csv file in a table format in SAS

Thank you very much! Appreciate your support!

Frequent Contributor
Posts: 92

Re: How to import a .csv file in a table format in SAS

Hi Cynthia,

 

How can i recall my directory  path as i am also facing error while uploading the csv file.

I have enrolled to 3 courses however dont find themm listed on my login screen.

 

Regards, Shivi

Ask a Question
Discussion stats
  • 8 replies
  • 3833 views
  • 4 likes
  • 4 in conversation