BookmarkSubscribeRSS Feed
lghansse
Calcite | Level 5

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

8 REPLIES 8
Mit
Calcite | Level 5 Mit
Calcite | Level 5

csv file da.ta path is required

lghansse
Calcite | Level 5

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.

Mit
Calcite | Level 5 Mit
Calcite | Level 5


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;

lghansse
Calcite | Level 5

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.


Mit
Calcite | Level 5 Mit
Calcite | Level 5

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;

lghansse
Calcite | Level 5

... 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 ';'.

snoopy369
Barite | Level 11

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; run;)

lghansse
Calcite | Level 5

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). . 😃

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1033 views
  • 3 likes
  • 3 in conversation