BookmarkSubscribeRSS Feed
k32
Calcite | Level 5 k32
Calcite | Level 5

Hi everyone, 

 

I've been trying to download this file (2018 BRFSS Data (SAS Transport Format) .cls-1{fill:#ffca28;}.cls-2{opacity:0.2;}.cls-3{fill:#3e2723;... ) from this link. However, it downloads as a XPT document on my MacBook. I've tried importing it but it doesn't open. Given that I'm not familiar with programming, this adds to my headache. 

 

Would someone kindly show me how to write a script to open it or download it and convert to an excel file for me please? I'm really distressed because I have spent 7+ hours on it but it still wouldn't open.

3 REPLIES 3
Reeza
Super User
libname sasfile '/folders/myfolders/';

libname xptfile xport '/folders/myfolders/NameofFile.xpt' access=readonly;

proc copy inlib=xptfile outlib=sasfile;
run;

@k32 wrote:

Hi everyone, 

 

I've been trying to download this file (2018 BRFSS Data (SAS Transport Format) .cls-1{fill:#ffca28;}.cls-2{opacity:0.2;}.cls-3{fill:#3e2723;... ) from this link. However, it downloads as a XPT document on my MacBook. I've tried importing it but it doesn't open. Given that I'm not familiar with programming, this adds to my headache. 

 

Would someone kindly show me how to write a script to open it or download it and convert to an excel file for me please? I'm really distressed because I have spent 7+ hours on it but it still wouldn't open.


Search terms: "import xpt file sas"

https://communities.sas.com/t5/SAS-Programming/Convert-XPT-to-SAS-Datasets/td-p/97872

ballardw
Super User

Please show the code you used to "import" the file.

The following code shows use of the XPORT library engine to connect to the file and then a data step to save the data from the transport file to a different library.

Use your paths and files. You can check on the contents of the xport library just like you would any other library.

 

libname xportin xport
'transport-file';
libname target 'SAS-data-library';
data target.grades;
   set xportin.grades;
run;
Tom
Super User Tom
Super User

Why would you want to go from one hard to use format to another?

That file is a ZIP file that contains a SAS version 5 transport file that contain a single SAS dataset.

So to use it in SAS all you need to do is first download the ZIP and then unzip it and point a libref at it.

libname xx xport 'c:\downloads\LLCP2018.XPT';
proc contents data=xx._all_; run;

The output of PROC CONTENTS shows that there is just one member in the xport file and it is named LLCP2028.

So to use the file directly just use code like:

proc means data=xx.LLCP2018; 
run;

If you really want to copy the datasets in the xport file into an Excel spreadsheet then make a second libref and use proc copy.

libname out xlsx  'c:\downloads\LLCP2018.xlsx';
proc copy inlib=xx outlib=out;
run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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