<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Proc FREQ: Deleting Observations? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proc-FREQ-Deleting-Observations/m-p/601512#M16726</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297876"&gt;@SAS93&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to use the 2017 BRFSS data to look at healthcare coverage (HLTHPLN1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The CDC has the HLTHPLN1 coded by:&lt;/P&gt;
&lt;P&gt;1=Yes&lt;/P&gt;
&lt;P&gt;2= no&lt;/P&gt;
&lt;P&gt;7=don't know&lt;/P&gt;
&lt;P&gt;9=refused&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to only look at YES and NO, so I'm trying to get rid of/delete those observations where HLTHPLN1=7 or 9. I've tried using the WHERE statement to just select those I'm interested in. I've tried the IF/Delete statement. I've tried with and without quotation marks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my code:&lt;/P&gt;
&lt;PRE&gt;Libname BRFSS '/folders/myfolders/';
Run;
Data BRFSS.BRF17HP;
	Set BRFSS.BRF17;
	If=(HLTHPLN1=1 or HLTHPLN1=2);
	If=(SEX=1 or SEX=2);
Run;
Proc sort data=BRFSS.BRF17HP;
	By SEX;
Proc surveyfreq data=BRFSS.BRF17;
	table HLTHPLN1;
	Strata _STSTR;
	Cluster _PSU;
	Weight _LLCPWT;
Run;

&lt;/PRE&gt;
&lt;P&gt;Here is log:&lt;/P&gt;
&lt;PRE&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         
 74         Libname BRFSS '/folders/myfolders/';
 NOTE: Libref BRFSS was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders
 75         Run;
 76         Data BRFSS.BRF17HP;
 77         Set BRFSS.BRF17;
 78         If=(HLTHPLN1=1 or HLTHPLN1=2);
 79         If=(SEX=1 or SEX=2);
 80         Run;
 
 NOTE: There were 5843 observations read from the data set BRFSS.BRF17.
 NOTE: The data set BRFSS.BRF17HP has 5843 observations and 359 variables.
 NOTE: DATA statement used (Total process time):
       real time           1.79 seconds
       cpu time            1.79 seconds
       
 
 81         Proc sort data=BRFSS.BRF17HP;
 82         By SEX;
 
 NOTE: There were 5843 observations read from the data set BRFSS.BRF17HP.
 NOTE: The data set BRFSS.BRF17HP has 5843 observations and 359 variables.
 NOTE: PROCEDURE SORT used (Total process time):
       real time           2.47 seconds
       cpu time            2.78 seconds
       
 
 83         Proc surveyfreq data=BRFSS.BRF17;
 84         table HLTHPLN1;
 85         Strata _STSTR;
 86         Cluster _PSU;
 87         Weight _LLCPWT;
 88         Run;
 
 NOTE: PROCEDURE SURVEYFREQ used (Total process time):
       real time           0.21 seconds
       cpu time            0.00 seconds
       
 
 89         
 90         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 102        

 
User: sasdemo
DATA Step Statements&lt;/PRE&gt;
&lt;P&gt;And here's the final output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.jpg" style="width: 347px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33609iA2A91C4A6DABDB0F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.jpg" alt="Untitled.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Clearly, my approach isn't working, because the categories for 7 and 9 are still there. &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What am I doing wrong, and how can I fix it?&lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Something else that you want to consider are the CDC added variables they use for analysis with the BRFSS data. These will have names that start with an _ . Depending on the analysis you want to perform you may find some things, such as age groups and some of the values that use 2 or more variables to determine such as BMI categories, already coded in the data. Labels are your friend.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Nov 2019 20:43:55 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-11-04T20:43:55Z</dc:date>
    <item>
      <title>Proc FREQ: Deleting Observations?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-FREQ-Deleting-Observations/m-p/601247#M16697</link>
      <description>&lt;P&gt;I'm trying to use the 2017 BRFSS data to look at healthcare coverage (HLTHPLN1).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The CDC has the HLTHPLN1 coded by:&lt;/P&gt;&lt;P&gt;1=Yes&lt;/P&gt;&lt;P&gt;2= no&lt;/P&gt;&lt;P&gt;7=don't know&lt;/P&gt;&lt;P&gt;9=refused&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to only look at YES and NO, so I'm trying to get rid of/delete those observations where HLTHPLN1=7 or 9. I've tried using the WHERE statement to just select those I'm interested in. I've tried the IF/Delete statement. I've tried with and without quotation marks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;PRE&gt;Libname BRFSS '/folders/myfolders/';
Run;
Data BRFSS.BRF17HP;
	Set BRFSS.BRF17;
	If=(HLTHPLN1=1 or HLTHPLN1=2);
	If=(SEX=1 or SEX=2);
Run;
Proc sort data=BRFSS.BRF17HP;
	By SEX;
Proc surveyfreq data=BRFSS.BRF17;
	table HLTHPLN1;
	Strata _STSTR;
	Cluster _PSU;
	Weight _LLCPWT;
Run;

&lt;/PRE&gt;&lt;P&gt;Here is log:&lt;/P&gt;&lt;PRE&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         
 74         Libname BRFSS '/folders/myfolders/';
 NOTE: Libref BRFSS was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders
 75         Run;
 76         Data BRFSS.BRF17HP;
 77         Set BRFSS.BRF17;
 78         If=(HLTHPLN1=1 or HLTHPLN1=2);
 79         If=(SEX=1 or SEX=2);
 80         Run;
 
 NOTE: There were 5843 observations read from the data set BRFSS.BRF17.
 NOTE: The data set BRFSS.BRF17HP has 5843 observations and 359 variables.
 NOTE: DATA statement used (Total process time):
       real time           1.79 seconds
       cpu time            1.79 seconds
       
 
 81         Proc sort data=BRFSS.BRF17HP;
 82         By SEX;
 
 NOTE: There were 5843 observations read from the data set BRFSS.BRF17HP.
 NOTE: The data set BRFSS.BRF17HP has 5843 observations and 359 variables.
 NOTE: PROCEDURE SORT used (Total process time):
       real time           2.47 seconds
       cpu time            2.78 seconds
       
 
 83         Proc surveyfreq data=BRFSS.BRF17;
 84         table HLTHPLN1;
 85         Strata _STSTR;
 86         Cluster _PSU;
 87         Weight _LLCPWT;
 88         Run;
 
 NOTE: PROCEDURE SURVEYFREQ used (Total process time):
       real time           0.21 seconds
       cpu time            0.00 seconds
       
 
 89         
 90         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 102        

 
User: sasdemo
DATA Step Statements&lt;/PRE&gt;&lt;P&gt;And here's the final output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.jpg" style="width: 347px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33609iA2A91C4A6DABDB0F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.jpg" alt="Untitled.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Clearly, my approach isn't working, because the categories for 7 and 9 are still there. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What am I doing wrong, and how can I fix it?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Nov 2019 18:44:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-FREQ-Deleting-Observations/m-p/601247#M16697</guid>
      <dc:creator>SAS93</dc:creator>
      <dc:date>2019-11-03T18:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Proc FREQ: Deleting Observations?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-FREQ-Deleting-Observations/m-p/601250#M16698</link>
      <description>&lt;P&gt;Please consider one of your statements:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If=(HLTHPLN1=1 or HLTHPLN1=2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What this actually does is create a variable called IF that is set to 1 if&amp;nbsp;HLTHPLN1=1 or HLTHPLN1=2, and 0 if not. Is doesn't filter your data at all. What I suspect you want is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If (HLTHPLN1=1 or HLTHPLN1=2); * Subsetting IF;

where (HLTHPLN1=1 or HLTHPLN1=2); * Subsetting WHERE;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;BTW, the brackets aren't necessary. You will get the same answer by removing them.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Nov 2019 19:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-FREQ-Deleting-Observations/m-p/601250#M16698</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-11-03T19:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc FREQ: Deleting Observations?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-FREQ-Deleting-Observations/m-p/601252#M16699</link>
      <description>&lt;P&gt;In addition to what &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt; said, I think the problem is here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc surveyfreq data=BRFSS.BRF17&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc surveyfreq data=BRFSS.BRF17&lt;FONT color="#FF0000"&gt;HP&lt;/FONT&gt;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Nov 2019 19:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-FREQ-Deleting-Observations/m-p/601252#M16699</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-03T19:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc FREQ: Deleting Observations?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-FREQ-Deleting-Observations/m-p/601353#M16715</link>
      <description>&lt;P&gt;Gosh darn it, the devil is always in the details! Thank you! I just needed a new pair of eyes looking at it apparently.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New code (that produces a matching output to the official one that I'm trying to check myself against):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Libname BRFSS '/folders/myfolders/';
Run;
Data BRFSS.BRF17HP;
	Set BRFSS.BRF17;
	If HLTHPLN1=1 then PLN='yes';
	If HLTHPLN1=2 then PLN='no';
	If SEX=1 then GEN='male';
	If SEX=2 then GEN='female';
Run;
Proc sort data=BRFSS.BRF17HP;
	By GEN;
Proc surveyfreq data=BRFSS.BRF17HP;
	table PLN;
	Strata _STSTR;
	Cluster _PSU;
	Weight _LLCPWT;
Run;


&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;To also mention, the IF statement vs WHERE statement is a really good tip&lt;/STRONG&gt;--I either forgot that concept or was never taught the difference. Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2019 12:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-FREQ-Deleting-Observations/m-p/601353#M16715</guid>
      <dc:creator>SAS93</dc:creator>
      <dc:date>2019-11-04T12:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc FREQ: Deleting Observations?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-FREQ-Deleting-Observations/m-p/601512#M16726</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297876"&gt;@SAS93&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to use the 2017 BRFSS data to look at healthcare coverage (HLTHPLN1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The CDC has the HLTHPLN1 coded by:&lt;/P&gt;
&lt;P&gt;1=Yes&lt;/P&gt;
&lt;P&gt;2= no&lt;/P&gt;
&lt;P&gt;7=don't know&lt;/P&gt;
&lt;P&gt;9=refused&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to only look at YES and NO, so I'm trying to get rid of/delete those observations where HLTHPLN1=7 or 9. I've tried using the WHERE statement to just select those I'm interested in. I've tried the IF/Delete statement. I've tried with and without quotation marks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my code:&lt;/P&gt;
&lt;PRE&gt;Libname BRFSS '/folders/myfolders/';
Run;
Data BRFSS.BRF17HP;
	Set BRFSS.BRF17;
	If=(HLTHPLN1=1 or HLTHPLN1=2);
	If=(SEX=1 or SEX=2);
Run;
Proc sort data=BRFSS.BRF17HP;
	By SEX;
Proc surveyfreq data=BRFSS.BRF17;
	table HLTHPLN1;
	Strata _STSTR;
	Cluster _PSU;
	Weight _LLCPWT;
Run;

&lt;/PRE&gt;
&lt;P&gt;Here is log:&lt;/P&gt;
&lt;PRE&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         
 74         Libname BRFSS '/folders/myfolders/';
 NOTE: Libref BRFSS was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders
 75         Run;
 76         Data BRFSS.BRF17HP;
 77         Set BRFSS.BRF17;
 78         If=(HLTHPLN1=1 or HLTHPLN1=2);
 79         If=(SEX=1 or SEX=2);
 80         Run;
 
 NOTE: There were 5843 observations read from the data set BRFSS.BRF17.
 NOTE: The data set BRFSS.BRF17HP has 5843 observations and 359 variables.
 NOTE: DATA statement used (Total process time):
       real time           1.79 seconds
       cpu time            1.79 seconds
       
 
 81         Proc sort data=BRFSS.BRF17HP;
 82         By SEX;
 
 NOTE: There were 5843 observations read from the data set BRFSS.BRF17HP.
 NOTE: The data set BRFSS.BRF17HP has 5843 observations and 359 variables.
 NOTE: PROCEDURE SORT used (Total process time):
       real time           2.47 seconds
       cpu time            2.78 seconds
       
 
 83         Proc surveyfreq data=BRFSS.BRF17;
 84         table HLTHPLN1;
 85         Strata _STSTR;
 86         Cluster _PSU;
 87         Weight _LLCPWT;
 88         Run;
 
 NOTE: PROCEDURE SURVEYFREQ used (Total process time):
       real time           0.21 seconds
       cpu time            0.00 seconds
       
 
 89         
 90         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 102        

 
User: sasdemo
DATA Step Statements&lt;/PRE&gt;
&lt;P&gt;And here's the final output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.jpg" style="width: 347px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33609iA2A91C4A6DABDB0F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.jpg" alt="Untitled.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Clearly, my approach isn't working, because the categories for 7 and 9 are still there. &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What am I doing wrong, and how can I fix it?&lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Something else that you want to consider are the CDC added variables they use for analysis with the BRFSS data. These will have names that start with an _ . Depending on the analysis you want to perform you may find some things, such as age groups and some of the values that use 2 or more variables to determine such as BMI categories, already coded in the data. Labels are your friend.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2019 20:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-FREQ-Deleting-Observations/m-p/601512#M16726</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-04T20:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proc FREQ: Deleting Observations?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-FREQ-Deleting-Observations/m-p/601519#M16727</link>
      <description>Hi:&lt;BR /&gt;  The syntax of your IF statement is incorrect. &lt;BR /&gt; &lt;BR /&gt;  Well, is it an IF statement? Or are you trying to create a new variable called IF? Or are you trying to subset the original data? And with a subsetting IF,  it's not clear what you want to do. &lt;BR /&gt;&lt;BR /&gt;  Do you want to ONLY get something like this:&lt;BR /&gt;	If HLTHPLN1 in (1,2) and &lt;BR /&gt;           SEX in (1,2);&lt;BR /&gt;or you could code it as &lt;BR /&gt;	If (HLTHPLN1 =1 or HLTHPLN1=2) and &lt;BR /&gt;           (SEX =1 or SEX=2);&lt;BR /&gt;&lt;BR /&gt;But your current syntax is probably creating a new variable called IF in the output data (which is why there's no error) and you can confirm that by running a PROC CONTENTS.&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;Cynthia&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Nov 2019 21:33:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-FREQ-Deleting-Observations/m-p/601519#M16727</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-11-04T21:33:12Z</dc:date>
    </item>
  </channel>
</rss>

