<?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 Add variable/observation to a macro in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Add-variable-observation-to-a-macro/m-p/826386#M35270</link>
    <description>&lt;P&gt;Hi I would like to add an additional calculation to replace the current date in the dataset -&amp;nbsp; 'CON_DATE_START = min(PL_DATE_START, SS_DATE_START);'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The original code is below: I am aware I cannot add variables/calculation to the proc sort step. I have tried to add an extra data step above the sort step, but then the final step of %if(length) is a macro variable linking to the step from the proc sort. Which my datastep will not work considering it returns to a normal output rather than a macro output. Could you please advise how I can add a macro variable step to add the calculation in.&amp;nbsp; Many Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sort&lt;BR /&gt;data=&amp;amp;lib..&amp;amp;customersdetail&lt;BR /&gt;out=_&amp;amp;customersdetail;&lt;BR /&gt;where also ANLAGE eq "&amp;amp;anlage";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%if %length(&amp;amp;anlage) %then _&amp;amp;customersdetail;&lt;BR /&gt;%else &amp;amp;lib..&amp;amp;customersdetail;&lt;BR /&gt;(rename=(DONOTBUY=_DONOTBUY)&lt;BR /&gt;where=(_DONOTBUY is missing))&lt;/P&gt;</description>
    <pubDate>Mon, 01 Aug 2022 05:00:43 GMT</pubDate>
    <dc:creator>miss2223</dc:creator>
    <dc:date>2022-08-01T05:00:43Z</dc:date>
    <item>
      <title>Add variable/observation to a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-variable-observation-to-a-macro/m-p/826386#M35270</link>
      <description>&lt;P&gt;Hi I would like to add an additional calculation to replace the current date in the dataset -&amp;nbsp; 'CON_DATE_START = min(PL_DATE_START, SS_DATE_START);'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The original code is below: I am aware I cannot add variables/calculation to the proc sort step. I have tried to add an extra data step above the sort step, but then the final step of %if(length) is a macro variable linking to the step from the proc sort. Which my datastep will not work considering it returns to a normal output rather than a macro output. Could you please advise how I can add a macro variable step to add the calculation in.&amp;nbsp; Many Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sort&lt;BR /&gt;data=&amp;amp;lib..&amp;amp;customersdetail&lt;BR /&gt;out=_&amp;amp;customersdetail;&lt;BR /&gt;where also ANLAGE eq "&amp;amp;anlage";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%if %length(&amp;amp;anlage) %then _&amp;amp;customersdetail;&lt;BR /&gt;%else &amp;amp;lib..&amp;amp;customersdetail;&lt;BR /&gt;(rename=(DONOTBUY=_DONOTBUY)&lt;BR /&gt;where=(_DONOTBUY is missing))&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 05:00:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-variable-observation-to-a-macro/m-p/826386#M35270</guid>
      <dc:creator>miss2223</dc:creator>
      <dc:date>2022-08-01T05:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable/observation to a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-variable-observation-to-a-macro/m-p/826394#M35271</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/229416"&gt;@miss2223&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%if %length(&amp;amp;anlage) %then _&amp;amp;customersdetail;&lt;BR /&gt;%else &amp;amp;lib..&amp;amp;customersdetail;&lt;BR /&gt;(rename=(DONOTBUY=_DONOTBUY)&lt;BR /&gt;where=(_DONOTBUY is missing))&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Unfortunately i don't understand what you are trying to do. I would be easier, if you post the data you have, the expected output and explain the rules that you want applied.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 06:08:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-variable-observation-to-a-macro/m-p/826394#M35271</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-08-01T06:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable/observation to a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-variable-observation-to-a-macro/m-p/826396#M35272</link>
      <description>&lt;P&gt;&lt;BR /&gt;Original data is &amp;amp;lib..&amp;amp;customersdetail&lt;BR /&gt;data original_data;&lt;BR /&gt;input var1$ CON_DATE_START PL_DATE_START SS_DATE_START;&lt;BR /&gt;datalines;&lt;BR /&gt;A 12/12/2008 11/01/2022 05/10/2007&lt;BR /&gt;B 19/01/2001 11/02/2008 01/03/2020&lt;BR /&gt;C 23/10/2008 02/08/2019 02/02/2010&lt;BR /&gt;D 01/09/2002 01/01/2000 19/03/2006;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;I want to replace the current CON_DATE_START, instead of that to use calculation CON_DATE_START = min(PL_DATE_START, SS_DATE_START)&lt;BR /&gt;Expecting to see:&lt;BR /&gt;var1 CON_DATE_START PL_DATE_START SS_DATE_START&lt;BR /&gt;A 05/10/2007 11/01/2022 05/10/2007&lt;BR /&gt;B 11/02/2008 11/02/2008 01/03/2020&lt;BR /&gt;C 02/02/2010 02/08/2019 02/02/2010&lt;BR /&gt;D 01/01/2000 01/01/2000 19/03/2006&lt;/P&gt;&lt;P&gt;Because the next step is in macro, I dont know how to link my replacement calculation of CON_DATE_START, so I dont need to change anything to below.&lt;/P&gt;&lt;P&gt;proc sort&lt;BR /&gt;data=&amp;amp;lib..&amp;amp;customersdetail&lt;BR /&gt;out=_&amp;amp;customersdetail;&lt;BR /&gt;where also ANLAGE eq "&amp;amp;anlage";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%if %length(&amp;amp;anlage) %then _&amp;amp;customersdetail;&lt;BR /&gt;%else &amp;amp;lib..&amp;amp;customersdetail;&lt;BR /&gt;(rename=(DONOTBUY=_DONOTBUY)&lt;BR /&gt;where=(_DONOTBUY is missing))&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 06:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-variable-observation-to-a-macro/m-p/826396#M35272</guid>
      <dc:creator>miss2223</dc:creator>
      <dc:date>2022-08-01T06:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable/observation to a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-variable-observation-to-a-macro/m-p/826408#M35273</link>
      <description>&lt;P&gt;The proc sort and following code non-valid sas code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can just insert another data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;

  con_start_date = min(pl_date_start, ss_date_start);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Aug 2022 10:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-variable-observation-to-a-macro/m-p/826408#M35273</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-08-01T10:39:36Z</dc:date>
    </item>
  </channel>
</rss>

