BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ZachC
Calcite | Level 5

Hello. I had previously used University Edition to convert SAS files to Stata files, and I used the following code: 

 

proc export data=home/u43327634/NHANES/17_18/DEMO_J.XPT
file='C:\Users\zachc\Desktop\test.dta'
dbms=stata
replace;
run;

 

However, my institution recently switched over to SAS OnDemand for Academics, and now that code doesn't work. It gives the following error message: 

ERROR 22-322: Expecting a name.
ERROR 200-322: The symbol is not recognized and will be ignored.
 
I'm not too fluent in SAS, I really just use it to convert to Stata files. Can you help?
 
Thanks,
Zach
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

In order to use the .xpt file, use a XPORT library:

libname xpt xport 'home/u43327634/NHANES/17_18/DEMO_J.XPT';

You can then treat library XPT like any other SAS library in your code; for instance, it will appear ion the Libraries section of SAS Studio.

View solution in original post

5 REPLIES 5
Kurt_Bremser
Super User

The DATA= option of the PROC EXPORT statement requires a dataset designation, comprised of (optional) a library name with a dot and the name of the dataset.

If you have an xpt file, you can define a LIBNAME for that.

ballardw
Super User

Your Data= does not expect an xpt file. It expects a libname.datasetname, such as work.something.

Your XPT file should have been copied to a library for use.

I suspect that your code didn't work with an XPT file before either, or if it did the file name was enclosed in quotes.

ZachC
Calcite | Level 5

Thank you for your reply. I followed the directions for how to set up a libname (https://support.sas.com/software/products/university-edition/faq/SAS_libname.htm),  but now I'm getting another error message when I run the following:

 

libname DEMO_J '/home/u43327634/NHANES/17_18/';

proc export data=DEMO_J
file='C:\Users\zachc\Desktop\test.dta'
dbms=stata
replace;
run;

 

Error Message: ERROR: Insufficient authorization to access /pbr/biconfig/940/Lev1/SASApp/C:\Users\zachc\Desktop.dta.

 

When you say that my XPT file should have been copied to a library for use, I'm not clear on what you mean. My XPT file is located in my SAS Studio file structure. Any more suggestions would be most welcome.

 

Kurt_Bremser
Super User

In SAS on Demand, you CANNOT access your desktop drive. CANNOT. Please study the "Frequently Asked Questions":

  • Can I point to local SAS data sets or files using a LIBNAME or a FILENAME statement?
    No. The SAS Server is unable to access or recognize the local drives of your PC. If you write a LIBNAME statement or a FILENAME statement that references a local directory path, you will receive processing errors.

 

You have to use a path in your home directory, same as you did for the LIBNAME, and then download the file with SAS Studio.

Kurt_Bremser
Super User

In order to use the .xpt file, use a XPORT library:

libname xpt xport 'home/u43327634/NHANES/17_18/DEMO_J.XPT';

You can then treat library XPT like any other SAS library in your code; for instance, it will appear ion the Libraries section of SAS Studio.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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