DATA Step, Macro, Functions and more

Proc export and spss value labels

Reply
New Contributor
Posts: 4

Proc export and spss value labels

[ Edited ]

Hello!

 

I'm looking for a way to get usable value/label pairs when using proc export to export datasets to spss dataset files (.sav). The formats are taken from our standard format catalog to using the fmtlib option. This produces good results when looking at the resulting dataset in SPSS - but only for both numeric values and strings with only numbers like "01". When the value is a string with characters, I get extraneous spaces and unwanted symbols added at the end of the value, like so:

 

clip.PNG

 

Code:

proc export data=data
outfile="path\file.sav"
dbms=sav replace;
fmtlib=FORMATS.FORMATS;
run;

 

Grateful for any ideas I can try to make this work.

 

Regards

Fredrik

 

Super User
Posts: 19,822

Re: Proc export and spss value labels

What about DBMS=SPSS?

New Contributor
Posts: 4

Re: Proc export and spss value labels

Thanks for replying Reeza!

I have now tried with DBMS=SPSS and the problem is still there unfortunately

Contributor
Posts: 65

Re: Proc export and spss value labels

Can you provide more info on the error that you are getting in the log...

New Contributor
Posts: 4

Re: Proc export and spss value labels

Posted in reply to DMoovendhan

There are no errors

Super User
Posts: 11,343

Re: Proc export and spss value labels

You say that you " get extraneous spaces and unwanted symbols added at the end of the value". Do you mean at the begining of the line? I don't see anything at the end in the displayed picture.

 

I am wondering if there might be an encoding issue involved, such as a UTF-8 to UTF-16 between the two programs.

 

 

New Contributor
Posts: 4

Re: Proc export and spss value labels

It does seem like an ecoding problem.

What I've tried so far is to set the encoding for file I want proc export to write to. I tried with using a filename statement and defining a .sav file with utf-8 encoding, before the proc export. SAS does create a .sav-file but then no data seems to be written to that file (no errors though).

 

ballardw: Look at the picture again. the values look like this:

"Value1     _=¾"

Super User
Posts: 19,822

Re: Proc export and spss value labels

I think it may be worth it to contact SAS Tech Support. 

Super User
Posts: 11,343

Re: Proc export and spss value labels

I think we are using END different context and I haven't looked at SPSS code in so long I don't remember the proper appearance for a Value statement.

 

If tech support can't help it may be easier to write some SPSS syntax from the SAS Data and/or format information that can be pasted into SPSS after opening the data set.

It has been long enough (more than 10 years) since I had to deal with SPSS so I don't think I can make a more specific suggestion.

If some of the SAS values are from formats then you might start with creating a CNTLOUT data set from the format libray involved.

Ask a Question
Discussion stats
  • 8 replies
  • 756 views
  • 1 like
  • 4 in conversation