BookmarkSubscribeRSS Feed
Cloudwilliam
Calcite | Level 5

Hello,

 

I downloaded a .xpt file for NHANES data. Could someone tell me how to open it with SAS?

 

 

2 REPLIES 2
Tom
Super User Tom
Super User

Use the LIBNAME statement to make a libref using the XPORT engine pointing at the file you downloaded.

You can then reference the dataset by its name or use PROC COPY to copy it to a different libref, such as WORK.

1     %let path=C:\Downloads;
2     libname nhanes xport "&path\DEMO_D.xpt";
NOTE: Libref NHANES was successfully assigned as follows:
      Engine:        XPORT
      Physical Name: C:\Downloads\DEMO_D.xpt
3     proc copy inlib=nhanes out=work;
4     run;

NOTE: Input library NHANES is sequential.
NOTE: Copying NHANES.DEMO_D to WORK.DEMO_D (memtype=DATA).
NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used.
NOTE: There were 10348 observations read from the data set NHANES.DEMO_D.
NOTE: The data set WORK.DEMO_D has 10348 observations and 43 variables.
NOTE: PROCEDURE COPY used (Total process time):
      real time           0.06 seconds
      cpu time            0.06 seconds
Ksharp
Super User

If your XPT is V8 version. Try this :

 

libname x v9 'c:\temp';
filename xpt 'c:\temp\temp.xpt';
%xpt2loc(libref=x,filespec=xpt)

SAS Help Center: SAS V8 Transport File Format

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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