<?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 Output data conditionally from a file with multi-record per line in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503332#M134476</link>
    <description>&lt;P&gt;the following code will read multi observations per line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data body_fat;&lt;BR /&gt;input Gender $ PercentFat @@;&lt;BR /&gt;datalines;&lt;BR /&gt;m 13.3 f 22&lt;BR /&gt;m 22 f 23.2&lt;BR /&gt;m 16 m 12&lt;BR /&gt;;&lt;BR /&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how do i populate the data with only M patients?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Oct 2018 08:40:13 GMT</pubDate>
    <dc:creator>Dennis_K</dc:creator>
    <dc:date>2018-10-11T08:40:13Z</dc:date>
    <item>
      <title>Output data conditionally from a file with multi-record per line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503332#M134476</link>
      <description>&lt;P&gt;the following code will read multi observations per line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data body_fat;&lt;BR /&gt;input Gender $ PercentFat @@;&lt;BR /&gt;datalines;&lt;BR /&gt;m 13.3 f 22&lt;BR /&gt;m 22 f 23.2&lt;BR /&gt;m 16 m 12&lt;BR /&gt;;&lt;BR /&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how do i populate the data with only M patients?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 08:40:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503332#M134476</guid>
      <dc:creator>Dennis_K</dc:creator>
      <dc:date>2018-10-11T08:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: Output data conditionally from a file with multi-record per line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503334#M134478</link>
      <description>&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;if gender="M" then output;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Oct 2018 08:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503334#M134478</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-11T08:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Output data conditionally from a file with multi-record per line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503335#M134479</link>
      <description>&lt;P&gt;Use a subsetting if:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data body_fat;
input Gender $ PercentFat @@;
if gender = 'm';
datalines;
m 13.3 f 22
m 22 f 23.2
m 16 m 12
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Oct 2018 08:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503335#M134479</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-11T08:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Output data conditionally from a file with multi-record per line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503336#M134480</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This looks a bit like homework. What have you tried so far? Share any code you have tried and show the log with any error messages.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you haven't tried anything yet then&amp;nbsp;try looking at the &lt;FONT face="courier new,courier"&gt;if&lt;/FONT&gt; statement documentation, which includes examples:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000202239.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000202239.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then you can post back your findings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 08:53:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503336#M134480</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2018-10-11T08:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Output data conditionally from a file with multi-record per line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503338#M134482</link>
      <description>data mbody_fat fbody_fat;&lt;BR /&gt;&lt;BR /&gt;input Gender $ PercentFat @@;&lt;BR /&gt;&lt;BR /&gt;IF Gender='m' then&lt;BR /&gt;output mbody_fat;&lt;BR /&gt;else IF Gender='f' then&lt;BR /&gt;output fbody_fat;&lt;BR /&gt;&lt;BR /&gt;datalines;&lt;BR /&gt;m 13.3 f 22&lt;BR /&gt;m 22 f 23.2&lt;BR /&gt;m 16 m 12&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Somehow the ELSE statement does not work</description>
      <pubDate>Thu, 11 Oct 2018 09:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503338#M134482</guid>
      <dc:creator>Dennis_K</dc:creator>
      <dc:date>2018-10-11T09:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Output data conditionally from a file with multi-record per line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503342#M134485</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I tried your code to split the genders, I had no apparent issues.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The M data set had 4 observations and the F data set had 2 observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;NOTE: The data set WORK.MBODY_FAT has 4 observations and 2 variables.
NOTE: The data set WORK.FBODY_FAT has 2 observations and 2 variables.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What do you get or what were you expecting?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 09:14:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503342#M134485</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2018-10-11T09:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: Output data conditionally from a file with multi-record per line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503343#M134486</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/128145"&gt;@Dennis_K&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;data mbody_fat fbody_fat;&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187967"&gt;@input&lt;/a&gt; Gender $ PercentFat @@;&lt;BR /&gt;&lt;BR /&gt;IF Gender='m' then&lt;BR /&gt;output mbody_fat;&lt;BR /&gt;else IF Gender='f' then&lt;BR /&gt;output fbody_fat;&lt;BR /&gt;&lt;BR /&gt;datalines;&lt;BR /&gt;m 13.3 f 22&lt;BR /&gt;m 22 f 23.2&lt;BR /&gt;m 16 m 12&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Somehow the ELSE statement does not work&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It &lt;EM&gt;does&lt;/EM&gt; work, see this log:&lt;/P&gt;
&lt;PRE&gt;27         data mbody_fat fbody_fat;
28         
29         input Gender $ PercentFat @@;
30         
31         IF Gender='m' then
32         output mbody_fat;
33         else IF Gender='f' then
34         output fbody_fat;
35         
36         datalines;

NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.MBODY_FAT has 4 observations and 2 variables.
NOTE: The data set WORK.FBODY_FAT has 2 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      
40         ;

41         run;
&lt;/PRE&gt;
&lt;P&gt;I just copy/pasted your code and ran it.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 09:14:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-data-conditionally-from-a-file-with-multi-record-per-line/m-p/503343#M134486</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-11T09:14:35Z</dc:date>
    </item>
  </channel>
</rss>

