BookmarkSubscribeRSS Feed
ckx
Quartz | Level 8 ckx
Quartz | Level 8

I'm trying to convert an older SPSS dataset from 2008 to SAS. This works for the most part but some labels and formats have a � symbol for special characters such as "mu" or a curly apostrophe. Is there any way I can properly convert these datasets?

 

I'm using SAS 9.4M8. I'm running SAS on LSAF (a special computing environment for pharma) so changing the character encoding on the SAS side isn't an option. Any suggestions?

 

2 REPLIES 2
ballardw
Super User

If you have an SPSS install and export the data to SAS with the correct options it should create a SAS program with Proc Format statements. 

Then you may be able to modify the format to use the special characters by use of unicode. You might still have issues with seeing the results properly depending on the SAS encoding if that doesn't support the unicode characters.

 

If you have to rely on the SAS import for SAV files then I suspect the only option will be to write data step code to modify the values to something your system will handle and possibly write a custom formats get the special characters to display using an acceptable font and/or unicode. Which may be long task if there are many of these special values.

 

Without knowing the required system encoding and font used can't provide anything better at this time.

 

Tom
Super User Tom
Super User

Is the symptom only that the characters are not displaying (stored using wrong encoding)?

Or is it causing the import step to fail and not create the DATASET and/or the format CATALOG?

 

If the former then perhaps you can fix the data after the import by using the ENCODING=ANY dataset option.

 

For example say the problem is only in the UNIT variable in the LAB dataset.Let's assume that the issue is that your SPSS file was made using UTF-8 encoding and your SAS session is running using WLATIN1 encoding.  Then you might using a step like this to convert the character.  

data lab_fixed;
  set lab(encoding=any);
  UNIT = kcvt(UNIT,'UTF-8','WLATIN1');
run;

If it is the reverse then you might need to make the UNIT variable longer since some characters that use only one byte in WLATIN1 could use more than one byte in UTF-8.

 

If the issue is in the FORMAT definition then use PROC FORMAT to make a DATASET from the format catalog.  Then use similar data step to fix the characters.  And then use another PROC FORMAT call to make a catalog from the fixed dataset.

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 229 views
  • 0 likes
  • 3 in conversation