<?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: Data manipulation - how to create a third variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/367220#M87399</link>
    <description>&lt;P&gt;Thank you!!!!&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2017 04:23:08 GMT</pubDate>
    <dc:creator>desireatem</dc:creator>
    <dc:date>2017-06-15T04:23:08Z</dc:date>
    <item>
      <title>Data manipulation - how to create a third variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365957#M86989</link>
      <description>&lt;P&gt;Create a fourth variable from first three:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
informat id $2. a b 8.;
input id $ A B ;
cards;
01 1 1
01 1 1
01 2 0
02 2 0
02 1 0
02 2 1
03 2 1
03 2 1
03 2 1
04 1 0
04 2 0
04 2 0
05 2 0
05 1 1 
05 2 0 
06 1 1 
06 2 1
06 2 1
06 2 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To create&lt;BR /&gt;For&amp;nbsp;a particular id, if A=1 firstly and subsequent A=2 for same id with B = 1 , then C=1.&lt;BR /&gt;But if for id A=2 firstly and subsquent A=1 for same id with B=1, then C=0. A=1 most preceed A=2 for C=1.&lt;/P&gt;
&lt;P&gt;id A B C &lt;BR /&gt;01 1 1 0&lt;BR /&gt;01 1 1 0&lt;BR /&gt;01 2 0 0&lt;BR /&gt;02 2 0 1&lt;BR /&gt;02 1 0 1&lt;BR /&gt;02 2 1 1&lt;BR /&gt;03 2 1 0&lt;BR /&gt;03 2 1 0 &lt;BR /&gt;03 2 1 0&lt;BR /&gt;04 1 0 0&lt;BR /&gt;04 2 0 0&lt;BR /&gt;04 2 0 0&lt;BR /&gt;05 2 0 0&lt;BR /&gt;05 1 1 0&lt;BR /&gt;05 2 0 0&lt;BR /&gt;06 1 1 1 &lt;BR /&gt;06 2 1 1&lt;BR /&gt;06 2 1 1&lt;BR /&gt;06 2 1 1&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 03:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365957#M86989</guid>
      <dc:creator>desireatem</dc:creator>
      <dc:date>2017-06-11T03:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Data manipulation - how to create a third variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365960#M86990</link>
      <description>&lt;P&gt;Note: I've moved this thread to the Base Programming as it is not related to SAS Data Integration Studio or SAS Data Flux where are Data Management Products/tools. Additionally, I've modified your post to correct spelling and to include the data as a data step. Please try to do these on your own in the future.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 03:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365960#M86990</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-11T03:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Data manipulation - how to create a third variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365963#M86991</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40563"&gt;@desireatem&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Please provide also a SAS datastep or at least a table which shows your desired output. This will help us to better understand the logic you describe so we don't spend time for a solution which doesn't return what you're after.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 03:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365963#M86991</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-06-11T03:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Data manipulation - how to create a third variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365968#M86993</link>
      <description>&lt;P&gt;&amp;nbsp;Please try&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
do until(last.id);
length codec$100.;
set have;
by id;
retain codec;
if a=1 then code='a';
else if a=2 then code='b';
if first.id then codec=code;
else codec=compress(catx('',codec,code));
if prxmatch('m/ab/oi',strip(codec)) and b=1 then c=1;
else if prxmatch('m/ba/oi',strip(codec)) and b=1 then c=0;
else c=0;
end;
do until(last.id);
set have;
by id;
output;
end;
drop code codec;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="lia-page"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 11 Jun 2017 04:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365968#M86993</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-06-11T04:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Data manipulation - how to create a third variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365970#M86995</link>
      <description>&lt;P&gt;Hello&amp;nbsp;Jag,&lt;/P&gt;
&lt;P&gt;Thank you.&amp;nbsp;let me verify.&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 04:42:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365970#M86995</guid>
      <dc:creator>desireatem</dc:creator>
      <dc:date>2017-06-11T04:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Data manipulation - how to create a third variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365971#M86996</link>
      <description>&lt;P&gt;Really like your solution&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 04:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365971#M86996</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-11T04:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: Data manipulation - how to create a third variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365972#M86997</link>
      <description>Thanks, correct</description>
      <pubDate>Sun, 11 Jun 2017 05:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365972#M86997</guid>
      <dc:creator>desireatem</dc:creator>
      <dc:date>2017-06-11T05:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Data manipulation - how to create a third variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365973#M86998</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40563"&gt;@desireatem&lt;/a&gt;&amp;nbsp;you marked the wrong solution correct.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 05:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/365973#M86998</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-11T05:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data manipulation - how to create a third variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/367220#M87399</link>
      <description>&lt;P&gt;Thank you!!!!&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 04:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-manipulation-how-to-create-a-third-variable/m-p/367220#M87399</guid>
      <dc:creator>desireatem</dc:creator>
      <dc:date>2017-06-15T04:23:08Z</dc:date>
    </item>
  </channel>
</rss>

