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.
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
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;
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;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.