BookmarkSubscribeRSS Feed
tallkell
Fluorite | Level 6

 

Hi,

I'm trying to convert my SAS dataset to Stata using the export procedure.

I have a dataset called 'survey' which I can successully export to Stata.

The resulting Stata file has the proper variable label. However, the formats does not carry over to the Stata dataset.

For example, a SAS variable 'sex' should have the format 1='Male, 2='Female'. The Stata dataset value label for sex is just '1' and '2'. I would preper that I don't have to code all the values in Stata.

 

Below is the export code i used.

 


libname data 'C:\data\';
libname library 'C:\Data\Formats';


proc export data=data.survey
file="C:\data\stata\survey"
dbms=STATA
replace;
fmtlib=library;
run;

 

 

Thanks for any guidance'

 

--Tim

 

1 REPLY 1
SASKiwi
PROC Star

Looks like your code is correct. Have you confirmed that your SURVEY dataset has the required formats defined on the columns prior to exporting? Also that your FORMATS catalog actually contains the formats - you can use proc format with the FMTLIB option for this.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 2333 views
  • 0 likes
  • 2 in conversation