<?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 Why are these coalesce or if\missing statements &amp;quot;retaining&amp;quot; data? in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Why-are-these-coalesce-or-if-missing-statements-quot-retaining/m-p/197191#M4339</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Some test code:&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;input cat1 $ cat2 $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;mortgage fixed&lt;/P&gt;&lt;P&gt;mortgage arm&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data two;&lt;/P&gt;&lt;P&gt;input group1 $ group2 $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;card standard&lt;/P&gt;&lt;P&gt;card reward&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data three;&lt;/P&gt;&lt;P&gt;set one two;&lt;/P&gt;&lt;P&gt;if missing(cat2) then cat2 = group2;&lt;/P&gt;&lt;P&gt;x = coalesceC(cat2, group2);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For Cards, why would cat2 and X end up as "standard" for both records??&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;mortgage&lt;/TD&gt;&lt;TD&gt;fixed&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;fixed&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;mortgage&lt;/TD&gt;&lt;TD&gt;arm&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;arm&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;standard&lt;/TD&gt;&lt;TD&gt;card&lt;/TD&gt;&lt;TD&gt;standard&lt;/TD&gt;&lt;TD&gt;standard&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;standard&lt;/TD&gt;&lt;TD&gt;card&lt;/TD&gt;&lt;TD&gt;reward&lt;/TD&gt;&lt;TD&gt;standard&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Aug 2015 20:43:41 GMT</pubDate>
    <dc:creator>wcp_fnfg</dc:creator>
    <dc:date>2015-08-11T20:43:41Z</dc:date>
    <item>
      <title>Why are these coalesce or if\missing statements "retaining" data?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Why-are-these-coalesce-or-if-missing-statements-quot-retaining/m-p/197191#M4339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Some test code:&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;input cat1 $ cat2 $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;mortgage fixed&lt;/P&gt;&lt;P&gt;mortgage arm&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data two;&lt;/P&gt;&lt;P&gt;input group1 $ group2 $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;card standard&lt;/P&gt;&lt;P&gt;card reward&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data three;&lt;/P&gt;&lt;P&gt;set one two;&lt;/P&gt;&lt;P&gt;if missing(cat2) then cat2 = group2;&lt;/P&gt;&lt;P&gt;x = coalesceC(cat2, group2);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For Cards, why would cat2 and X end up as "standard" for both records??&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;mortgage&lt;/TD&gt;&lt;TD&gt;fixed&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;fixed&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;mortgage&lt;/TD&gt;&lt;TD&gt;arm&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;arm&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;standard&lt;/TD&gt;&lt;TD&gt;card&lt;/TD&gt;&lt;TD&gt;standard&lt;/TD&gt;&lt;TD&gt;standard&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;standard&lt;/TD&gt;&lt;TD&gt;card&lt;/TD&gt;&lt;TD&gt;reward&lt;/TD&gt;&lt;TD&gt;standard&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 20:43:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Why-are-these-coalesce-or-if-missing-statements-quot-retaining/m-p/197191#M4339</guid>
      <dc:creator>wcp_fnfg</dc:creator>
      <dc:date>2015-08-11T20:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Why are these coalesce or if\missing statements "retaining" data?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Why-are-these-coalesce-or-if-missing-statements-quot-retaining/m-p/197192#M4340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CAT2 is RETAINed because it is coming from one of the datasets on the SET statement.&amp;nbsp; All such variables are retained.&amp;nbsp; It only appears not to be retained because the SET statement fills it with new values (or when you reach the end missing values).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You do not normally notice is this type of program because you normally do not assign a value one of the variables from your INPUT dataset after you have read past the end.&lt;/P&gt;&lt;P&gt;Add a couple of PUT statements and you can see what is happening.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BEFORE: dsname=&amp;nbsp; cat1=&amp;nbsp; cat2=&amp;nbsp; group1=&amp;nbsp; group2=&amp;nbsp; x=&amp;nbsp; _ERROR_=0 _N_=1&lt;/P&gt;&lt;P&gt;AFTER: dsname=WORK.ONE cat1=mortgage cat2=fixed group1=&amp;nbsp; group2=&amp;nbsp; x=fixed _ERROR_=0 _N_=1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BEFORE: dsname=WORK.ONE cat1=mortgage cat2=fixed group1=&amp;nbsp; group2=&amp;nbsp; x=&amp;nbsp; _ERROR_=0 _N_=2&lt;/P&gt;&lt;P&gt;AFTER: dsname=WORK.ONE cat1=mortgage cat2=arm group1=&amp;nbsp; group2=&amp;nbsp; x=arm _ERROR_=0 _N_=2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BEFORE: dsname=WORK.ONE cat1=mortgage cat2=arm group1=&amp;nbsp; group2=&amp;nbsp; x=&amp;nbsp; _ERROR_=0 _N_=3&lt;/P&gt;&lt;P&gt;AFTER: dsname=WORK.TWO cat1=&amp;nbsp; cat2=standard group1=card group2=standard x=standard _ERROR_=0 _N_=3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BEFORE: dsname=WORK.TWO cat1=&amp;nbsp; cat2=standard group1=card group2=standard x=&amp;nbsp; _ERROR_=0 _N_=4&lt;/P&gt;&lt;P&gt;AFTER: dsname=WORK.TWO cat1=&amp;nbsp; cat2=standard group1=card group2=reward x=standard _ERROR_=0 _N_=4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BEFORE: dsname=WORK.TWO cat1=&amp;nbsp; cat2=standard group1=card group2=reward x=&amp;nbsp; _ERROR_=0 _N_=5&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 21:44:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Why-are-these-coalesce-or-if-missing-statements-quot-retaining/m-p/197192#M4340</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-08-11T21:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: Why are these coalesce or if\missing statements "retaining" data?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Why-are-these-coalesce-or-if-missing-statements-quot-retaining/m-p/197193#M4341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Besides retaining SET statement variables, there's one more complicating factor, which PUT messages can't capture 100% because it's part of SET statement execution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When, if ever, should the software reinitialize CAT2 to missing?&amp;nbsp; The answer is when reading the first observation from the data set TWO.&amp;nbsp; When reading the first observation from a data set, SET statement variables that do not appear in that data set get reset to missing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 22:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Why-are-these-coalesce-or-if-missing-statements-quot-retaining/m-p/197193#M4341</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-08-11T22:41:00Z</dc:date>
    </item>
  </channel>
</rss>

