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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 686 views
  • 0 likes
  • 3 in conversation