<?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: Conditionally Output New Observations to Dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-Output-New-Observations-to-Dataset/m-p/601981#M174216</link>
    <description>&lt;P&gt;While I don't quite understand your algorithm, the answer is definitely yes, you can output conditionally to whatever data set you want.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data boys girls;
    set sashelp.class;
    if sex='F' then output girls;
    else if sex='M' then output boys;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Nov 2019 13:46:48 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-11-06T13:46:48Z</dc:date>
    <item>
      <title>Conditionally Output New Observations to Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-Output-New-Observations-to-Dataset/m-p/601843#M174140</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've got some conditions and dates I'd like to process and make new observations from.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, I'm starting from the following:&lt;/P&gt;&lt;PRE&gt;data have; 
input cond1 cond2 start end; 
datalines; 
1 0 4075 4965&lt;BR /&gt;1 0 5025 5763 
0 1 4333 5322
 ;
 run;&lt;/PRE&gt;&lt;P&gt;And I'd like to process the above such that I get the following:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; 
input cond1 cond2 start end; 
datalines; 
1 0 4075 4333 
1 1 4333 4965
0 1 4965 5025
1 1 5025 5322
1 0 5322 5763 
; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course there are several more possible permutations to this as start and end are date variables that can vary in range between the conditions, but I'll only be handling 2 conditions at a time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if SAS could utilize multiple output statements within a conditional step in order to output multiple observations? I'm also happy to hear other strategies of approach as well. Thus far I've been sorting and my&amp;nbsp;data&amp;nbsp;many different ways to try to get a handle on how best detect and create new observations, but have had a lot of trouble coming up with a solution that fits even just the above situation. I'm wondering if I should give each condition their own set of date variables and attempt to reconcile them from there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 01:17:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-Output-New-Observations-to-Dataset/m-p/601843#M174140</guid>
      <dc:creator>solfay243</dc:creator>
      <dc:date>2019-11-06T01:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally Output New Observations to Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-Output-New-Observations-to-Dataset/m-p/601981#M174216</link>
      <description>&lt;P&gt;While I don't quite understand your algorithm, the answer is definitely yes, you can output conditionally to whatever data set you want.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data boys girls;
    set sashelp.class;
    if sex='F' then output girls;
    else if sex='M' then output boys;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Nov 2019 13:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-Output-New-Observations-to-Dataset/m-p/601981#M174216</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-06T13:46:48Z</dc:date>
    </item>
  </channel>
</rss>

