<?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: how to add a variable to the data, if corresponding row have one of the values greater than a nu in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-a-variable-to-the-data-if-corresponding-row-have-one/m-p/357415#M83909</link>
    <description>&lt;P&gt;You could use a variable list using -- (Double dash)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so for example: max(of a--d);&lt;/P&gt;</description>
    <pubDate>Wed, 10 May 2017 10:11:05 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2017-05-10T10:11:05Z</dc:date>
    <item>
      <title>how to add a variable to the data, if corresponding row have one of the values greater than a number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-a-variable-to-the-data-if-corresponding-row-have-one/m-p/357408#M83903</link>
      <description>&lt;P&gt;Hi i am stuck with basic prob.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two&amp;nbsp;datasets &lt;STRONG&gt;Data1&lt;/STRONG&gt; having variables a, b, c, d like&amp;nbsp;&lt;/P&gt;&lt;P&gt;a b c d&lt;/P&gt;&lt;P&gt;2 3 5 6&lt;/P&gt;&lt;P&gt;1 0 1 4&lt;/P&gt;&lt;P&gt;0 1 4 5&lt;/P&gt;&lt;P&gt;2 4 3 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and &lt;STRONG&gt;Data2 &lt;/STRONG&gt;having variables ch and lm&lt;/P&gt;&lt;P&gt;ch lm&lt;/P&gt;&lt;P&gt;p &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;q &amp;nbsp; 5&lt;/P&gt;&lt;P&gt;l &amp;nbsp; &amp;nbsp;7&lt;/P&gt;&lt;P&gt;m &amp;nbsp;4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I Need my &lt;STRONG&gt;output&lt;/STRONG&gt;&amp;nbsp;having variables ch (&lt;STRONG&gt;Data2&lt;/STRONG&gt;), (a,b,c,d) from &lt;STRONG&gt;Data1&lt;/STRONG&gt; and a new variable "label" having "1" if any of the value in the row of &lt;STRONG&gt;data1 &lt;/STRONG&gt;is &amp;gt;= 5.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my &lt;STRONG&gt;output&lt;/STRONG&gt; data will have variables "ch", "a"," b", "c", "d", "label".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 09:42:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-a-variable-to-the-data-if-corresponding-row-have-one/m-p/357408#M83903</guid>
      <dc:creator>ervinodsingh</dc:creator>
      <dc:date>2017-05-10T09:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to add a variable to the data, if corresponding row have one of the values greater than a nu</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-a-variable-to-the-data-if-corresponding-row-have-one/m-p/357409#M83904</link>
      <description>&lt;P&gt;I don't have a sound understanding of your req nor your data. Is this what you want?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; want;&lt;/P&gt;&lt;P&gt;merge data2(drop=lm) data1;&lt;/P&gt;&lt;P&gt;if max(a,b,c,d)&amp;gt;=&lt;STRONG&gt;5&lt;/STRONG&gt; then label=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 09:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-a-variable-to-the-data-if-corresponding-row-have-one/m-p/357409#M83904</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-05-10T09:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to add a variable to the data, if corresponding row have one of the values greater than a nu</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-a-variable-to-the-data-if-corresponding-row-have-one/m-p/357412#M83906</link>
      <description>&lt;P&gt;Sir&amp;nbsp;Thanks for your quick response,&lt;/P&gt;&lt;P&gt;Actually, It was a toy example.&lt;/P&gt;&lt;P&gt;Can you generalize if i have too many variables in Data1.&amp;nbsp;So, &amp;nbsp;i can't put them manually.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 10:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-a-variable-to-the-data-if-corresponding-row-have-one/m-p/357412#M83906</guid>
      <dc:creator>ervinodsingh</dc:creator>
      <dc:date>2017-05-10T10:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to add a variable to the data, if corresponding row have one of the values greater than a nu</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-a-variable-to-the-data-if-corresponding-row-have-one/m-p/357415#M83909</link>
      <description>&lt;P&gt;You could use a variable list using -- (Double dash)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so for example: max(of a--d);&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 10:11:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-a-variable-to-the-data-if-corresponding-row-have-one/m-p/357415#M83909</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-05-10T10:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to add a variable to the data, if corresponding row have one of the values greater than a nu</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-a-variable-to-the-data-if-corresponding-row-have-one/m-p/357417#M83911</link>
      <description>&lt;P&gt;Given that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You need to examine every numeric variable in Data1, and&lt;/LI&gt;
&lt;LI&gt;The new variable is based on variables in Data1 only,&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;You would be better off creating the new variable first, and combining the data sets later. &amp;nbsp;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data data1_new;&lt;/P&gt;
&lt;P&gt;set data1;&lt;/P&gt;
&lt;P&gt;label = (max(of _numeric_) &amp;gt;= 5);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then do combine them, you can use either SET or MERGE. &amp;nbsp;It depends on what you want the result to be if there are different numbers of observations in DATA1 and DATA2. &amp;nbsp;Here is one possibility to consider:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set data1_new;&lt;/P&gt;
&lt;P&gt;set data2 (drop=lm);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 10:19:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-a-variable-to-the-data-if-corresponding-row-have-one/m-p/357417#M83911</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-10T10:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to add a variable to the data, if corresponding row have one of the values greater than a nu</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-a-variable-to-the-data-if-corresponding-row-have-one/m-p/357418#M83912</link>
      <description>&lt;P&gt;Thanks Austonding.. yours code is also working&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 10:37:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-a-variable-to-the-data-if-corresponding-row-have-one/m-p/357418#M83912</guid>
      <dc:creator>ervinodsingh</dc:creator>
      <dc:date>2017-05-10T10:37:22Z</dc:date>
    </item>
  </channel>
</rss>

