DATA Step, Macro, Functions and more

convert SAS file to SPSS

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 124
Accepted Solution

convert SAS file to SPSS

Hi,

I have to convert a sas file to spss . The original sas dataset can only be opened after a proc format statement is run to account for the new formats. After that , I am able to open the sas dataset. Can this dataset then be converted to a spss file using the following program

get sas data='c:\sas\data\class.xpt'.
execute.

How can I ensure proper conversion. Please advice on the steps.

Thanks!


Accepted Solutions
Solution
‎11-06-2015 03:58 PM
Super User
Posts: 19,772

Re: convert SAS file to SPSS

Then try proc export.
To ensure formatted variables transfer properly I have a habit of including both the formatted and unformatted variable. Sometimes I also convert the formatted variable using a PUT() statement as well. It depends on the data.

View solution in original post


All Replies
Super User
Posts: 19,772

Re: convert SAS file to SPSS

Are you working in SPSS or SAS?
If you want an SPSS file, export to SPSS and use the appropriate DBMS, either SAV or SPSS.
Frequent Contributor
Posts: 124

Re: convert SAS file to SPSS

@Reeza,  I am working in sas.

Solution
‎11-06-2015 03:58 PM
Super User
Posts: 19,772

Re: convert SAS file to SPSS

Then try proc export.
To ensure formatted variables transfer properly I have a habit of including both the formatted and unformatted variable. Sometimes I also convert the formatted variable using a PUT() statement as well. It depends on the data.
Frequent Contributor
Posts: 124

Re: convert SAS file to SPSS

The unformatetd varibale is not present for this variable in the dataset. That's the reason for my concern. I will have to create a new one representing the unformatted one and then transfer. Would that be a good step?

Super User
Posts: 19,772

Re: convert SAS file to SPSS

I consider it best practice myself Smiley Happy
Frequent Contributor
Posts: 124

Re: convert SAS file to SPSS

Thanks. Then I will make sure to have it. I have one more question. For the variable 'title' with the format...I have to run the proc format statement first. Say the format name for it is 'west'. After I run the proic format then only I am able to open the sas dataset in lib=work. If not it triggers a message saying


NOTE: Format WEST was not found or could not be loaded.
NOTE: There were 437 observations read from the data set WORK.ORIGINAL.
NOTE: The data set WORK.TEMP has 437 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

 

When I run a proc contents on work.temp I see the format 'west' listed against the vairiable 'title'. However, when I look at the column attributes of the variable in the dataset, the format is listed as BESTX12.

 

What is 'bestx12.' ? Please let me know.

Frequent Contributor
Posts: 124

Re: convert SAS file to SPSS

Please ignore my alst question. Thanks for your help.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 466 views
  • 0 likes
  • 2 in conversation