<?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 create a variable from three variables in  a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498985#M132719</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(catt(VAR1,VAR2,VAR3),'1') then VAR4='Y';
else var4='N'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;//Fredrik&lt;/P&gt;</description>
    <pubDate>Wed, 26 Sep 2018 08:10:03 GMT</pubDate>
    <dc:creator>FredrikE</dc:creator>
    <dc:date>2018-09-26T08:10:03Z</dc:date>
    <item>
      <title>How to create a variable from three variables in  a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498959#M132700</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello guys,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I' m new to the forum.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please how do i create a new variable from 3 variables (cbrchyr, copdev, ephev).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;My goal is to create a variable that would pick, for example, a&amp;nbsp; "YES" response (coded as 1) in ANY of the variables cbrchyr, copdev and ephev to mean&amp;nbsp; a "Yes" response in my new variable. While the remaining responses that are not "YES" (coded as 2,7,8,9)&amp;nbsp; are coded as 2 (NO).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have attached a copy of my output. I want to create a variable that would list obs 27, 37, 38, 44 and 47 as Yes (1).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please i'll be glad to get any kind of help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Below is my inital code. I have used the "coalsce" statement and i just can't get it right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;LIBNAME perm 'D:\';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DATA Newsasdata (keep= cbrchyr copdev ephev );&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SET perm.nhis2012sampleadult;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RUN;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 262px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23528i3BC349350C6F6586/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 06:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498959#M132700</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2018-09-26T06:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a variable from three variables in  a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498965#M132705</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(catt(VAR1,VAR2,VAR3),'1') then VAR4='Y';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 06:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498965#M132705</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-26T06:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a variable from three variables in  a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498970#M132708</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;It worked. My other question is, how do i code the other observations as "2" in my new variable (var 4)&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.JPG" style="width: 294px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23529i46C5AC10ED0AFB24/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture2.JPG" alt="Capture2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 07:02:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498970#M132708</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2018-09-26T07:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a variable from three variables in  a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498981#M132715</link>
      <description>&lt;P&gt;To paraphrase&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;var4=ifn(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;index&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;catt&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(var&lt;/SPAN&gt;1&lt;SPAN class="token punctuation"&gt;,var&lt;/SPAN&gt;2&lt;SPAN class="token punctuation"&gt;,var&lt;/SPAN&gt;3&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'1'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;),1,2)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;So if the first parameter is true, return 1, else return 2&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 08:03:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498981#M132715</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-26T08:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a variable from three variables in  a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498983#M132717</link>
      <description>&lt;P&gt;Thanks Chris!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 08:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498983#M132717</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2018-09-26T08:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a variable from three variables in  a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498985#M132719</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(catt(VAR1,VAR2,VAR3),'1') then VAR4='Y';
else var4='N'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;//Fredrik&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 08:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498985#M132719</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2018-09-26T08:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a variable from three variables in  a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498987#M132720</link>
      <description>&lt;P&gt;Thanks guys!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 08:12:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/498987#M132720</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2018-09-26T08:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a variable from three variables in  a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/499295#M132840</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236266"&gt;@ChuksManuel&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Really?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You&amp;nbsp;never used ELSE before?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 22:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-variable-from-three-variables-in-a-dataset/m-p/499295#M132840</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-26T22:12:30Z</dc:date>
    </item>
  </channel>
</rss>

