<?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: Finding records with a specific value for a specific variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598905#M172790</link>
    <description>&lt;P&gt;&amp;gt;&lt;SPAN&gt;how can I see which study IDs have -1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;How do you want to "see"?&amp;nbsp; Creating a table seems the best way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data BAD;
   set MYHOSPRECORDS;
   where TOTAL_LENGTH_OF_STAY = -1 ;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Even better you don't need to create table, you can directly run a report using any procedure, by just adding the same WHERE clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Oct 2019 03:24:42 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-10-24T03:24:42Z</dc:date>
    <item>
      <title>Finding records with a specific value for a specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598865#M172759</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am fairly new to SAS and I am using SAS 9.4.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with a data set (hospital inpatient records) that has about one hundred thousand records and about forty variables. Each patient has their unique study ID. Some of the variables are birth-date, admission-date, separation-date, 15 variables for ICD codes of diagnoses of each patient, dead or alive flag, etc. One of the variables is total_length_of_stay and documents for the datasheet say "invalid data will be recorded as -1".&amp;nbsp; My question is how can I see which study IDs have -1 in their&amp;nbsp;total_length_of_stay. Right now the only way I can do this is with use of a flag:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data myhosprecords;&lt;/P&gt;&lt;P&gt;set myhosprecords;&lt;/P&gt;&lt;P&gt;if&amp;nbsp;total_length_of_stay = -1 then invalidlength=1;&lt;/P&gt;&lt;P&gt;else invalidlength=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data invalidlengthofstay validlengthofstay;&lt;/P&gt;&lt;P&gt;set myhosprecords;&lt;/P&gt;&lt;P&gt;if invalidlength=1 then output invalidlengthofstay;&lt;/P&gt;&lt;P&gt;else output validlengthofstay;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a simpler way without creating a flag and two other datasheets to find those individuals whose total_length_of_stay = -1?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 23:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598865#M172759</guid>
      <dc:creator>Primavera</dc:creator>
      <dc:date>2019-10-23T23:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Finding records with a specific value for a specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598867#M172760</link>
      <description>&lt;P&gt;Do it in one step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data invalidlengthofstay validlengthofstay;
 set myhosprecords;
	if total_length_of_stay = -1 
	   then output invalidlengthofstay;
           else output validlengthofstay;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Oct 2019 23:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598867#M172760</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-10-23T23:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Finding records with a specific value for a specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598905#M172790</link>
      <description>&lt;P&gt;&amp;gt;&lt;SPAN&gt;how can I see which study IDs have -1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;How do you want to "see"?&amp;nbsp; Creating a table seems the best way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data BAD;
   set MYHOSPRECORDS;
   where TOTAL_LENGTH_OF_STAY = -1 ;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Even better you don't need to create table, you can directly run a report using any procedure, by just adding the same WHERE clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 03:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598905#M172790</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-10-24T03:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Finding records with a specific value for a specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598919#M172801</link>
      <description>&lt;P&gt;Thank you very much. Your suggestion is very neat and efficient.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By seeing I meant seeing the result in the "Results Viewer" window without needing to create the new file "BAD". I&amp;nbsp; looked into proc print but that did not seem like what I wanted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;&lt;SPAN&gt;Even better you don't need to create table, you can directly run a report using any procedure, by just adding the same WHERE clause.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please explain this a bit further?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 04:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598919#M172801</guid>
      <dc:creator>Primavera</dc:creator>
      <dc:date>2019-10-24T04:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Finding records with a specific value for a specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598921#M172803</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=myhosprecords(where=(total_length_of_stay = -1)); run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;use the where statement to select required observations.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 05:07:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598921#M172803</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-10-24T05:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: Finding records with a specific value for a specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598922#M172804</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;Could you please explain this a bit further?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm#n1xbr9r0s9veq0n137iftzxq4g7e.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm#n1xbr9r0s9veq0n137iftzxq4g7e.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're welcome.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;"Results Viewer" window&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;DMS or EG?&amp;nbsp; Both support a where clause.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 05:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598922#M172804</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-10-24T05:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Finding records with a specific value for a specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598924#M172805</link>
      <description>&lt;P&gt;Exactly what I was looking for. Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 05:29:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-records-with-a-specific-value-for-a-specific-variable/m-p/598924#M172805</guid>
      <dc:creator>Primavera</dc:creator>
      <dc:date>2019-10-24T05:29:53Z</dc:date>
    </item>
  </channel>
</rss>

