BookmarkSubscribeRSS Feed
ginak
Quartz | Level 8

hello,

I was wondering how I can export my sas data set, along with its formats, to an spss data set? If I use the export feature from file > export data, I get an error message saying "

ERROR: The format YESNOM was not found or could not be loaded.

ERROR: The format YESNOM was not found or could not be loaded.

ERROR: The format YESNOM was not found or could not be loaded.

ERROR: The format BLANK was not found or could not be loaded.

ERROR: The format YESNOM was not found or could not be loaded.

ERROR: The format BLANK was not found or could not be loaded."

etc.

So I looked it up online and am having trouble writing the correct code. My library is called "h" and my data set is called "april17" so, it is h.april17. my format file is h.formatsMAR27.

If I put this in

LIBNAME h SPSS XPORT "E:\work\codebook\CBTdata.dat";

proc formats library=library cntlout=formts;

proc copy in=h out = cbt; select april17; run ;

SAS tells me "ERROR: Libname H is not assigned."

How can I export the data set with its formats so my PI can read in the data set to SPSS?

Thanks!'

ps I tried using this website but it was confusing http://staff.washington.edu/glynn/sasspss.pdf

,

3 REPLIES 3
Ksharp
Super User

But the code you posted is making a transport file , not exporting it to SPSS .

You can search it at support.sas.com . then will find lots of example from SAS to SPSS.

LIBNAME h XPORT "E:\work\codebook\CBTdata.dat"

ginak
Quartz | Level 8

Thanks, I looked again. Originally, this is what I had found on the support.sas.com website:

"

This example exports the SAS data set SDF.CUSTOMER, to the SPSS file, CUSTOMER.SAV, on a local system.

LIBNAME SDF "&sasdir"; PROC EXPORT DATA=SDF.CUSTOMER FILE="&tmpdir.customer.sav" DBMS=SPSS REPLACE; RUN;

"

But this didn't tell me how to export formats.

I found another code:

proc export data=h.april17

  outfile ="E:\work\codebook\cbtdataset.sav"

  dbms=sav replace;

  fmtlib=h.formatsMAR27;

run;

I'm not sure if this will work? because I got the error message:

ERROR: The format HELPTHIR was not found or could not be loaded.

But I'm not sure when I used that alleged format in my data set.. what's the fastest way to check that? I have re-written my .sas files many times Smiley Sad

Ksharp
Super User

Hi.

From the URL you posted, it said that if you want these SAS format when you export SPSS file ,you only can use V6 version SAS datasets. and the URL has already given you all the steps of transforming SAS file into SPSS file.

1)If you want to bring formats along, you must create a version 6 file of the formats.

The following is SAS code.Asssuming you have a SAS dataset named w3sf21 under d:\dl\sas_spss\ .

libname library 'd:\dl\sas_spss\' ; * specify where SAS files (i.e. SAS datasets) are;

libname ver6 v6 'd:\dl\sas_spss\v6'; * specify a new directory(i.e. V6 engine) - no SAS files in it ;

options compress = no ; * compression must be off ;

* Write version 6 file of data and formats to new directory, using V6 engine ;

data ver6.w3sf21 ; set library.w3sf21 ;

proc format library = library cntlout = ver6.sas_fmts ;

run ;

2)This will create two files in the directory(i.e. d:\dl\sas_spss\v6) you have created for your version 6 file. In the above example, they would be called “w3sf21.sd2” and “sas_fmts.sd2”.

In SPSS, you would issue the command (changing file definitions to match your file):

get sas data='d:\dl\sas_spss\v6\w3sf21.sd2'/ FORMATS='d:\dl\sas_spss\v6\sas_fmts.sd2'

Ksharp

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
  • 3 replies
  • 1873 views
  • 0 likes
  • 2 in conversation