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.

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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