Help using Base SAS procedures

Problems when importing a file into SAS

Reply
Occasional Contributor
Posts: 5

Problems when importing a file into SAS

Hey,

I'm fairly new to working with SAS and I'm struggeling with the following problem:

I'm trying to import a file (originally SPSS-format) into SAS. I've already tried saving it as a excel-file (extension.xls), a SAS-database file (extension sas.7bdat) or a comma delimited file (extension .csv). SAS does import the file but states that the dataset contains only 1 observation and 0 variables. However, when I look at my data with the proc print-command there are over 50000 oberservations. I do see that all my variabels are stated in one collumn and their values are separated with ';'. This problem occurs with each of the data-formats and I have no idea on what the solution could be.

To be clear this is the syntax I use:

proc import OUT=WORK.filename

datafile="file_location_and_name.csv"

       dbms=csv

     replace;

       getnames=yes;

  run;

Thanks,

Lise

Frequent Contributor
Frequent Contributor
Posts: 83

Re: Problems when importing a file into SAS

csv file da.ta path is required

Occasional Contributor
Posts: 5

Re: Problems when importing a file into SAS

Could you explain this?

If you mean that I should add a 'delimiter'-statement, I already tried that and it didn't make any difference.

Frequent Contributor
Frequent Contributor
Posts: 83

Re: Problems when importing a file into SAS


You should mention the path of this file ie. where this file is located. suppose your file is located at "C:\My Documents"

dbms is your delimiter type.


proc import

datafile="C:\My Documents\file_location_and_name.csv"

OUT=WORK.filename

       dbms=csv

     replace;

       getnames=yes;

  run;

Occasional Contributor
Posts: 5

Re: Problems when importing a file into SAS

I did that. It's just not specified id syntax I typed above (I just put file_location_and_name) but I did it correctly in SAS.


Frequent Contributor
Frequent Contributor
Posts: 83

Re: Problems when importing a file into SAS

Suppose your file name is mydata then the following code should work.

Please ref to

Base SAS(R) 9.2 Procedures Guide



proc import

datafile="C:\My Documents\mydata.csv"

OUT=WORK.filename

       dbms=csv

     replace;

       getnames=yes;

  run;

Occasional Contributor
Posts: 5

Re: Problems when importing a file into SAS

... which is the same syntax as I suggested.

Namely:

proc import

datafile="S\QUALICOPC\DATABANKEN\werkdatabanken\ecometrics\voorbereiding datasets schalen\organisatorische access.csv"

OUT=WORK.org_access

       dbms=csv

     replace;

       getnames=yes;

  run;

However, I tried yours and it still gives the same problem.SAS still says there is only one variable in the dataset, while the table shows the values of all my variables (about 9) but seperated by a ';'.

Super Contributor
Posts: 253

Re: Problems when importing a file into SAS

Sounds to me like it's not comma separated, but semicolon separated.

proc import file=whatever out=whatever dbms=dlm dlm=';' replace;

getnames=yes;

run;

(using same options as your code, just dbms=dlm and dlm=';' )

Also, do you have ACCESS to PC FILES licensed?  PROC IMPORT can read in an SPSS file.  (proc import file="whatever.sav" out=whatever dbms=SPSS replace; runSmiley Wink

Occasional Contributor
Posts: 5

Re: Problems when importing a file into SAS

Posted in reply to snoopy369

Snoopy,

Thank you! First option didn't work, but when I directly imported an SPSS file it did (didn't know that was possible, so thanks a lot). . =)

Ask a Question
Discussion stats
  • 8 replies
  • 329 views
  • 3 likes
  • 3 in conversation