<?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: Issue combining datasets and modifying data in the same step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645137#M192797</link>
    <description>&lt;P&gt;All data set variables are retained until overwritten by another data set value. That's the way a data step works.&lt;BR /&gt;Since TEST1 doesn't overwrite the value, IDENTIFIER stays untouched across iterations. IDENTIFIER is changed by your code when its value is blank. Thereafter it's not blank so the test fails and it remains as is.&lt;/P&gt;</description>
    <pubDate>Tue, 05 May 2020 02:12:05 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2020-05-05T02:12:05Z</dc:date>
    <item>
      <title>Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645091#M192767</link>
      <description>&lt;P&gt;HI, I am having an issue combining datasets and I am looking for help as to what is going on.&lt;/P&gt;&lt;P&gt;I have two datasets, all fields are character.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;get_test1_nodup has the following data:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Spot_2&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Spot_4&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Spot_3&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;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/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I combine the datasets with the following code:&lt;BR /&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; combine;&lt;/P&gt;&lt;P&gt;set &amp;nbsp;&amp;nbsp;get_test1_nodup&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get_test2_nodup&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;if identifier ='' then identifier=Spot_2||Spot_4||Spot_3;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the resulting dataset:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;orig_identifier&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;identifier&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Spot_2&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Spot_4&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;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TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The identifier field did not compute as I intended. Take the second row for example, identifier should be 171, not 172.&amp;nbsp; What is causing this? Furthermore, where is it getting the 172 value its putting in the field? I have resolved this by combining the datasets first and then creating another dataset with the if statement, but why can't it be done in one step? I'd like to understand what is going on here.&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 20:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645091#M192767</guid>
      <dc:creator>jhealthpolicy</dc:creator>
      <dc:date>2020-05-04T20:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645096#M192769</link>
      <description>&lt;P&gt;Because IDENTIFIER is coming from one of the input datasets it is RETAINed (that it it is NOT reset to missing at the start of the data step iteration).&amp;nbsp; But it is NOT in TEST1. So when you read a new observation from TEST1 the value does not change.&amp;nbsp; So the test in your IF statement fails after the first observation from TEST1 since IDENTIFIER is no longer blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could create a NEW variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_identifier = coalescec(identifier, cats(Spot_2,Spot_4,Spot_3));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use IN= dataset option variables to drive your IF/THEN statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data combine;
  set get_test1_nodup (in=in1)
      get_test2_nodup (in=in2)
  ;
  if in1 then identifier=Spot_2||Spot_4||Spot_3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 20:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645096#M192769</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-04T20:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645125#M192790</link>
      <description>&lt;P&gt;In other words:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Because IDENTIFIER is coming from one of the input data sets it is RETAINed, &lt;STRONG&gt;and only reset when read again from a data set&lt;/STRONG&gt;. Since it is not present in TEST1, it is never reset as long as TEST1 is read. And since it takes a value on the first iteration, it keeps this value until it is read from TEST2 and is not blank.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can create a new variable, or you can test the source:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;data COMBINE;
  set TEST1 (in=TEST1)
      TEST2 ;
  if TEST1 | IDENTIFIER = ' ' then IDENTIFIER=catt(SPOT_2,SPOT_4,SPOT_3) ;
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 22:31:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645125#M192790</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-04T22:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645136#M192796</link>
      <description>&lt;P&gt;I think i'm starting to understand. Why does it retain the value by default?&amp;nbsp; I thought that was the job of the retain statement?&amp;nbsp; Would you elaborate on why it satisfies the if condition on the first obs, but not on any subsequent records on the first dataset? I dont see how SAS sees it as blank for only the first record.&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 00:11:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645136#M192796</guid>
      <dc:creator>jhealthpolicy</dc:creator>
      <dc:date>2020-05-05T00:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645137#M192797</link>
      <description>&lt;P&gt;All data set variables are retained until overwritten by another data set value. That's the way a data step works.&lt;BR /&gt;Since TEST1 doesn't overwrite the value, IDENTIFIER stays untouched across iterations. IDENTIFIER is changed by your code when its value is blank. Thereafter it's not blank so the test fails and it remains as is.&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 02:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645137#M192797</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-05T02:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645138#M192798</link>
      <description>&lt;P&gt;That is how data steps work.&amp;nbsp; You normally don't notice because most steps are in the form:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
  set old;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So the first thing the iteration does is read in the data from the old dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is why one to many merges can work.&amp;nbsp; The observation from the dataset with just one observation is read the first time and then the values for the variables it is contributing stay the same until the next set of BY values are reached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 01:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645138#M192798</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-05T01:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645139#M192799</link>
      <description>&lt;P&gt;Apropos of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt; 's explanation, you could easiliy fix with an explict OUTPUT statement followed by a CALL MISSING.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data combine;
  set   get_test1_nodup
        get_test2_nodup   ;
  if identifier ='' then identifier=Spot_2||Spot_4||Spot_3;
  output;
  call missing(of _all_);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 May 2020 01:20:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645139#M192799</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-05-05T01:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645142#M192802</link>
      <description>&lt;P&gt;Or even&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;data combine;
  call missing(of _all_);
  set get_test1_nodup
      get_test2_nodup ;
  if identifier ='' then identifier=Spot_2||Spot_4||Spot_3;
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 02:09:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645142#M192802</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-05T02:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645143#M192803</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Or even&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;data combine;
  call missing(of _all_);
  set get_test1_nodup
      get_test2_nodup ;
  if identifier ='' then identifier=Spot_2||Spot_4||Spot_3;
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That cannot work, because of the way that the _ALL_ keyword is evaluated at the point it is seen, not after all of the data step has been compiled.&amp;nbsp; In fact it won't even run.&lt;/P&gt;
&lt;PRE&gt;1193  data combine;
1194    call missing(of _all_);
             -------
             252
ERROR 252-185: The MISSING subroutine call does not have enough arguments.

1195    set test1 test2 ;
1196    if identifier ='' then identifier=Spot_2||Spot_4||Spot_3;
1197  run;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 May 2020 02:22:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645143#M192803</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-05T02:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645144#M192804</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Of course you are right.&lt;/P&gt;
&lt;P&gt;Something like this would work&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;data combine;
  length identifier $20;
  identifier = ' ' ;
  set get_test1_nodup
      get_test2_nodup ;
  if identifier ='' then identifier=Spot_2||Spot_4||Spot_3;
run;&lt;/LI-CODE&gt;
&lt;P&gt;but is is not shorter or clearer than&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;'s proposal.&lt;/P&gt;
&lt;P&gt;I was keen to emphasize that variables could be processed at the top of the data step, before the SET statement is encountered, but my example fell flat on its face...&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 02:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645144#M192804</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-05T02:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645147#M192807</link>
      <description>&lt;P&gt;Why does it satisfy the if statement on the first observation?&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 02:44:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645147#M192807</guid>
      <dc:creator>jhealthpolicy</dc:creator>
      <dc:date>2020-05-05T02:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645148#M192808</link>
      <description>Because identifier is blank.&lt;BR /&gt;</description>
      <pubDate>Tue, 05 May 2020 02:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645148#M192808</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-05T02:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645150#M192810</link>
      <description>&lt;P&gt;So on the first obs it is blank, but all lines after that they are missing (therefore not satisfying the if statement)? I guess i'm not understanding why the first one it evaluates as blank, but after that they are evaluated as missing.&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 03:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645150#M192810</guid>
      <dc:creator>jhealthpolicy</dc:creator>
      <dc:date>2020-05-05T03:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645152#M192812</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;&amp;nbsp;I guess i'm not understanding why the first one it evaluates as blank, but after that they are evaluated as missing.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;blank and missing are the same thing for a string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 03:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645152#M192812</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-05T03:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645160#M192819</link>
      <description>&lt;P&gt;I just read the first few pages of the sas paper on the program data vector and reread all of these responses 5 times.&lt;/P&gt;&lt;P&gt;My understanding of the dataset creation is as follows:&lt;/P&gt;&lt;P&gt;1. The data step initializes and creates a list of all variables from both test1 and test2.&lt;/P&gt;&lt;P&gt;2. In the PDV, all variables are initialized to missing(according to the sas document) and all variables are retained until another round of the by statement.&lt;/P&gt;&lt;P&gt;3. The first iteration of reading in values for each variable from test1 occurs. It pulls in all values for all matching variables, but because test1 does not have the identifier variable, it keeps its value of missing.&lt;/P&gt;&lt;P&gt;4. My if statement is processed, because it is missing, it combines spot 2, 3, 4.&lt;/P&gt;&lt;P&gt;5. The next iteration of the datastep is executed, because identifier is not on the first dataset, it retains the value from the previous step due to the automatic retain in step 2 above.&lt;/P&gt;&lt;P&gt;6. This loop continues until identifier has a value, in this case from the test2 dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The paper i am referencing(page 3):&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings13/125-2013.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings13/125-2013.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do i understand the process correctly?&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 04:26:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645160#M192819</guid>
      <dc:creator>jhealthpolicy</dc:creator>
      <dc:date>2020-05-05T04:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645162#M192821</link>
      <description>&lt;P style="box-sizing: border-box; color: #333333; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; margin: 0px;"&gt;"There's more than one way to skin a cat".&amp;nbsp; So here's another way.&amp;nbsp; It has no explicit output and no call missing.&amp;nbsp; But it does take advantage of a DROP= parameter and conditional SET statement.&amp;nbsp; And it eliminates the unintended carry forward of &lt;STRIKE&gt;stay&lt;/STRIKE&gt; stale identifier values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data combine;
  set   get_test1_nodup
        get_test2_nodup  (drop=identifier in=in2);
  identifier=Spot_2||Spot_4||Spot_3;
  if in2 then set get_test2_nodup;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The crucial point here is that the conditional SET is explicitly synchronized with reading data from get_test2_nodup in the unconditional SET. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 02:37:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645162#M192821</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-05-06T02:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645199#M192839</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;Do i understand the process correctly?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Perfectly!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 08:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645199#M192839</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-05T08:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Issue combining datasets and modifying data in the same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645671#M193045</link>
      <description>&lt;P&gt;Thank you everyone for the replies -- this was very educational.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 18:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-combining-datasets-and-modifying-data-in-the-same-step/m-p/645671#M193045</guid>
      <dc:creator>jhealthpolicy</dc:creator>
      <dc:date>2020-05-06T18:20:27Z</dc:date>
    </item>
  </channel>
</rss>

