BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SAS93
Quartz | Level 8

I'm using the 2017 BRFSS Annual Survey data with SAS UE. I've successfully converted the XPT file to a SAS file. My VMWare Fusion has a solid shared folder with my Google Drive; it's never given me issues.

 

Here is my code for converting.

 

DM OUTPUT 'clear' continue;
DM LOG    'clear' continue;
OPTIONS PAGENO=1 NOFMTERR;
TITLE ;
FOOTNOTE ;
RUN ;


LIBNAME TRANSPRT XPORT '/folders/myfolders/BRFSS/LLCP2017.XPT';
LIBNAME DATAOUT V7 '/folders/myfolders/BRFSS/'  ;
PROC COPY IN=TRANSPRT OUT=DATAOUT;
RUN;

 

 

I want to begin using this sas file, but I can't figure out how to. I've tried creating new libraries, using infile statements and a few other ways that just don't seem to be working. I've never had to convert or re-link to a new SAS file, so it's got me stumped.

 

I want to start by creating a new dataset that has only information where _STATE=47 (Tennessee).

 

What do I do?

 

Here is the log for my code given above:

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         DM OUTPUT 'clear' continue;
 74         DM LOG    'clear' continue;
 75         OPTIONS PAGENO=1 NOFMTERR;
 76         TITLE ;
 77         FOOTNOTE ;
 78         RUN ;
 79         
 80         
 81         LIBNAME TRANSPRT XPORT '/folders/myfolders/BRFSS/LLCP2017.XPT';
 NOTE: Libref TRANSPRT was successfully assigned as follows: 
       Engine:        XPORT 
       Physical Name: /folders/myfolders/BRFSS/LLCP2017.XPT
 82         LIBNAME DATAOUT V7 '/folders/myfolders/BRFSS/'  ;
 NOTE: Libref DATAOUT was successfully assigned as follows: 
       Engine:        V7 
       Physical Name: /folders/myfolders/BRFSS
 83         PROC COPY IN=TRANSPRT OUT=DATAOUT;
 84         RUN;
 
 NOTE: Input library TRANSPRT is sequential.
 NOTE: Copying TRANSPRT.LLCP2017 to DATAOUT.LLCP2017 (memtype=DATA).
 NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used.
 NOTE: There were 450016 observations read from the data set TRANSPRT.LLCP2017.
 NOTE: The data set DATAOUT.LLCP2017 has 450016 observations and 358 variables.
 NOTE: PROCEDURE COPY used (Total process time):
       real time           4:05.62
       cpu time            4:02.00
       
 
 85         
 86         
 87         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 99         

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Does your library DATAOUT actually have the data set LLCP2017? The notes say that it should. That would be your data to work with.

 

Can you run Proc Contents on Dataout.LLCP2017?

If so the next step would likely be to subset the data

 

Data datout.tenn;

    set dataout.llcp2017;

    where _state=47; /* possibly ='47', I don't know whether the _state variable is character or numeric*/

run;

View solution in original post

3 REPLIES 3
ballardw
Super User

Does your library DATAOUT actually have the data set LLCP2017? The notes say that it should. That would be your data to work with.

 

Can you run Proc Contents on Dataout.LLCP2017?

If so the next step would likely be to subset the data

 

Data datout.tenn;

    set dataout.llcp2017;

    where _state=47; /* possibly ='47', I don't know whether the _state variable is character or numeric*/

run;

SAS93
Quartz | Level 8

Thank you! I think I tried something similar to that, but it didn't work. I tried it this way, and it worked. For anyone who comes across this same silly issue in the future, here is my final code:

 

DM OUTPUT 'clear' continue;
DM LOG    'clear' continue;
OPTIONS PAGENO=1 NOFMTERR;
TITLE ;
FOOTNOTE ;
RUN ;


LIBNAME TRANSPRT XPORT '/folders/myfolders/BRFSS/LLCP2017.XPT';
LIBNAME DATAOUT V7 '/folders/myfolders/BRFSS/'  ;
PROC COPY IN=TRANSPRT OUT=DATAOUT;
RUN;

*Create new Library to store working dataset;
Libname BRFSS '/folders/myfolders/';
Run;
Data BRFSS.BRF17;
	Set dataout.llcp2017;
	Where _STATE=47;
Run;

Proc surveyfreq data=BRFSS.BRF17;
	table HAVARTH3;
	Strata _STSTR;
	Weight _LLCPWT;
Run;

I also found this blog post to be helpful in figuring out this problem:

Satisfaction with Life and Income: A Secondary Data Analysis Using the BRFSS 2010 Survey 

ballardw
Super User

@SAS93 wrote:

Thank you! I think I tried something similar to that, but it didn't work. I tried it this way, and it worked. For anyone who comes across this same silly issue in the future, here is my final code:

 

DM OUTPUT 'clear' continue;
DM LOG    'clear' continue;
OPTIONS PAGENO=1 NOFMTERR;
TITLE ;
FOOTNOTE ;
RUN ;


LIBNAME TRANSPRT XPORT '/folders/myfolders/BRFSS/LLCP2017.XPT';
LIBNAME DATAOUT V7 '/folders/myfolders/BRFSS/'  ;
PROC COPY IN=TRANSPRT OUT=DATAOUT;
RUN;

*Create new Library to store working dataset;
Libname BRFSS '/folders/myfolders/';
Run;
Data BRFSS.BRF17;
	Set dataout.llcp2017;
	Where _STATE=47;
Run;

Proc surveyfreq data=BRFSS.BRF17;
	table HAVARTH3;
	Strata _STSTR;
	Weight _LLCPWT;
Run;

I also found this blog post to be helpful in figuring out this problem:

Satisfaction with Life and Income: A Secondary Data Analysis Using the BRFSS 2010 Survey 


You likely need to include  CLUSTER _PSU ; and should almost certainly use the Proc option NOMCAR (not missing completely at random) with BRFSS data as a fair amount of the missing data comes from skip patterns in the code, i.e. do not answer some questions because of response to a previous question.

 

I've worked with BRFSS data off and on since 1997 so have some familiarity with the likely syntax.

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!

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
  • 3 replies
  • 624 views
  • 2 likes
  • 2 in conversation