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
csv file da.ta path is required
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.
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;
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.
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;
... 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 ';'.
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;)
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). . 😃
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.