<?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: Create a new variable based on two others in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/732119#M228127</link>
    <description>&lt;P&gt;Don't just use the length of $20 from my sample but chose a length which matches your source variables. If the length is too short then you will truncate the string, if it's too long then you're wasting space.&lt;/P&gt;
&lt;P&gt;You can run below script. Then look-up in the report what lengths your two source variables have and use the bigger of the two values in the length statement for your new variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=DEM_MES.MERGEEFATURADMRSS202001;
run;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Apr 2021 00:32:36 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-04-08T00:32:36Z</dc:date>
    <item>
      <title>Create a new variable based on two others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731860#M228010</link>
      <description>&lt;P&gt;I have this dataset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;and I want to create a new variable based on C3 and C3_F.&lt;/P&gt;&lt;P&gt;When C3 has a value I want this value. When not, like the green example shown, I want the C3_F value.&lt;/P&gt;&lt;P&gt;Can you help me please?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 14:03:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731860#M228010</guid>
      <dc:creator>ramgouveia</dc:creator>
      <dc:date>2021-04-12T14:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on two others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731862#M228011</link>
      <description>&lt;P&gt;You could use the coalescec() function documented &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p1g9btrql8d9x6n1iz6yowaqrq1v.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;here&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 00:28:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731862#M228011</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-08T00:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on two others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731864#M228012</link>
      <description>Patrick&lt;BR /&gt;&lt;BR /&gt;The link doesn't work.</description>
      <pubDate>Wed, 07 Apr 2021 11:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731864#M228012</guid>
      <dc:creator>ramgouveia</dc:creator>
      <dc:date>2021-04-07T11:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on two others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731868#M228014</link>
      <description>&lt;P&gt;The link works for me.&lt;/P&gt;
&lt;P&gt;Here how this could look like in a data step. Make sure to define the length of new_var long enough to hold the string (=the greater length of your two source variables)&lt;/P&gt;
&lt;PRE&gt;length new_var $20;
new_var=coalescec(cae3,cae3_fue);
&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Apr 2021 12:02:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731868#M228014</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-07T12:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on two others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731878#M228020</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; the link does not work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;Whitelabel Error Page&lt;/H1&gt;
&lt;P&gt;This application has no explicit mapping for /error, so you are seeing this as a fallback.&lt;/P&gt;
&lt;DIV id="created"&gt;Wed Apr 07 12:26:11 UTC 2021&lt;/DIV&gt;
&lt;DIV&gt;There was an unexpected error (type=Not Found, status=404).&lt;/DIV&gt;</description>
      <pubDate>Wed, 07 Apr 2021 12:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731878#M228020</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-04-07T12:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on two others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731882#M228022</link>
      <description>&lt;P&gt;I took the liberty to update the link, it should work now everywhere.&lt;/P&gt;
&lt;P&gt;(I just copy/pasted the link that I get from the documentation website, I have no clue what was wrong)&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 12:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731882#M228022</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-07T12:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on two others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731898#M228025</link>
      <description>&lt;P&gt;Thank you very much &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; !&lt;BR /&gt;&lt;BR /&gt;It worked!&lt;BR /&gt;&lt;BR /&gt;I used this code:&lt;BR /&gt;&lt;BR /&gt;DATA D;&lt;BR /&gt;set D;&lt;BR /&gt;length C3_E $20.;&lt;BR /&gt;C3_E=coalescec(c3,c3_f);&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 14:04:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/731898#M228025</guid>
      <dc:creator>ramgouveia</dc:creator>
      <dc:date>2021-04-12T14:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on two others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/732118#M228126</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 00:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/732118#M228126</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-08T00:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on two others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/732119#M228127</link>
      <description>&lt;P&gt;Don't just use the length of $20 from my sample but chose a length which matches your source variables. If the length is too short then you will truncate the string, if it's too long then you're wasting space.&lt;/P&gt;
&lt;P&gt;You can run below script. Then look-up in the report what lengths your two source variables have and use the bigger of the two values in the length statement for your new variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=DEM_MES.MERGEEFATURADMRSS202001;
run;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Apr 2021 00:32:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-two-others/m-p/732119#M228127</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-08T00:32:36Z</dc:date>
    </item>
  </channel>
</rss>

