<?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 Printing only a few observations from a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Printing-only-a-few-observations-from-a-variable/m-p/702086#M215032</link>
    <description>&lt;P&gt;I'm trying to create a table using specific variables from a dataset. The issue I'm having is that I need to use a certain subset of one specific variable and cannot figure out how.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a sample of the original dataset:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA  Study;
  INPUT SSN $11. WtLb BMI SBP CODCd $13.;
  DATALINES;
999-99-9999 150 22.7 176 Stroke
000-00-0000 130 26.5 160 Heart Failure
...&lt;BR /&gt;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For the table, I want to use only the values where CODCd is Heart Failure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I already have, which essentially only formats the table:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;TITLE1 "Subjects Dead from Heart Failure";
PROC PRINT DATA = Study

ID SSN;
VAR WtLb BMI SBP;
RUN;
TITLE;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How can I print only the observations where CODCd is Heart Failure? I'm not sure if it matters, but in the actual original dataset the variable CODCd is numeric.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Dec 2020 15:15:25 GMT</pubDate>
    <dc:creator>sdevenny</dc:creator>
    <dc:date>2020-12-10T15:15:25Z</dc:date>
    <item>
      <title>Printing only a few observations from a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Printing-only-a-few-observations-from-a-variable/m-p/702086#M215032</link>
      <description>&lt;P&gt;I'm trying to create a table using specific variables from a dataset. The issue I'm having is that I need to use a certain subset of one specific variable and cannot figure out how.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a sample of the original dataset:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA  Study;
  INPUT SSN $11. WtLb BMI SBP CODCd $13.;
  DATALINES;
999-99-9999 150 22.7 176 Stroke
000-00-0000 130 26.5 160 Heart Failure
...&lt;BR /&gt;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For the table, I want to use only the values where CODCd is Heart Failure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I already have, which essentially only formats the table:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;TITLE1 "Subjects Dead from Heart Failure";
PROC PRINT DATA = Study

ID SSN;
VAR WtLb BMI SBP;
RUN;
TITLE;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How can I print only the observations where CODCd is Heart Failure? I'm not sure if it matters, but in the actual original dataset the variable CODCd is numeric.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 15:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Printing-only-a-few-observations-from-a-variable/m-p/702086#M215032</guid>
      <dc:creator>sdevenny</dc:creator>
      <dc:date>2020-12-10T15:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Printing only a few observations from a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Printing-only-a-few-observations-from-a-variable/m-p/702089#M215034</link>
      <description>&lt;PRE&gt;TITLE1 "Subjects Who Died from Heart Failure";
PROC PRINT DATA = Study
SPLIT = '*';
Where CODCd ="Heart Failure";
LABEL	WtLb = 'Subject*Weight'
		BMI = 'Body*Mass*Index'
		SBP = 'Systolic*Blood*Pressure'
		SSN = 'Soc Sec Number';
ID SSN;
VAR WtLb BMI SBP;
RUN;
TITLE;&lt;/PRE&gt;
&lt;P&gt;The Where statement is available in many procedures to process only records where a condition is true.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 18:37:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Printing-only-a-few-observations-from-a-variable/m-p/702089#M215034</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-27T18:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Printing only a few observations from a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Printing-only-a-few-observations-from-a-variable/m-p/702094#M215037</link>
      <description>&lt;P&gt;I've tried the WHERE statement, and got this in the log:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ERROR: WHERE clause operator requires compatible variables.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 18:52:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Printing-only-a-few-observations-from-a-variable/m-p/702094#M215037</guid>
      <dc:creator>sdevenny</dc:creator>
      <dc:date>2020-11-27T18:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: Printing only a few observations from a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Printing-only-a-few-observations-from-a-variable/m-p/702097#M215038</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/344422"&gt;@sdevenny&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;How can I print only the observations where CODCd is Heart Failure? I'm not sure if it matters, but in the actual original dataset the variable CODCd is numeric.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/344422"&gt;@sdevenny&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This sounds like "Heart Failure" is only the &lt;EM&gt;formatted&lt;/EM&gt; value of the numeric variable CODCd. In this case use the PUT function and the appropriate format name (maybe something like &lt;FONT face="courier new,courier"&gt;CODCdFmt&lt;/FONT&gt;, see PROC CONTENTS output) in the WHERE statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where put(CODCd, CODCdFmt.)='Heart Failure';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or define the subset in a preliminary DATA step&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hf / view=hf;
set study;
if vvalue(CODCd)='Heart Failure';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then use &lt;FONT face="courier new,courier"&gt;hf&lt;/FONT&gt; (without a WHERE statement) in the PROC PRINT step:&lt;/P&gt;
&lt;PRE&gt;proc print data=&lt;STRONG&gt;hf&lt;/STRONG&gt; ...;
...&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Nov 2020 19:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Printing-only-a-few-observations-from-a-variable/m-p/702097#M215038</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-11-27T19:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Printing only a few observations from a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Printing-only-a-few-observations-from-a-variable/m-p/702102#M215040</link>
      <description>&lt;P&gt;Hello!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A WHERE statement is necessary. You will want to make sure you use whatever unformatted value you want for CODc.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 15:14:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Printing-only-a-few-observations-from-a-variable/m-p/702102#M215040</guid>
      <dc:creator>traciplummer</dc:creator>
      <dc:date>2020-12-10T15:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: Printing only a few observations from a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Printing-only-a-few-observations-from-a-variable/m-p/702110#M215042</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/344422"&gt;@sdevenny&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I've tried the WHERE statement, and got this in the log:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ERROR: WHERE clause operator requires compatible variables.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your example data has the variable of concern as a character variable. When you misrepresent your data it makes it much harder to come up with proper answers.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 20:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Printing-only-a-few-observations-from-a-variable/m-p/702110#M215042</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-27T20:12:01Z</dc:date>
    </item>
  </channel>
</rss>

