<?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 flag in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-a-flag/m-p/47487#M9829</link>
    <description>source                 Outlet             price1 price2&lt;BR /&gt;
DDD                    08536148           350 260&lt;BR /&gt;
CVS                    08536148          350 260&lt;BR /&gt;
DDD                    08852148         1000 400&lt;BR /&gt;
CVS                    08852148          350 260&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Yes,&lt;BR /&gt;
I gave the order of the outlets wrongly in the OP.for the same outlets from different sources we need to set a flag if their prices are equal.&lt;BR /&gt;
as in the case of first two records.</description>
    <pubDate>Thu, 09 Dec 2010 15:38:46 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2010-12-09T15:38:46Z</dc:date>
    <item>
      <title>create a flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-flag/m-p/47485#M9827</link>
      <description>I'm using union all on two data sources so that record from data source is arranged sequentially (one after the other,based on the sort condition).How to create a flag 'Y' if the records from each datasource have the same value.for instance:&lt;BR /&gt;
&lt;BR /&gt;
source          Outlet                             price1                price2&lt;BR /&gt;
DDD           08536148                          350                     260&lt;BR /&gt;
CVS           08852148                          350                     260&lt;BR /&gt;
DDD           08536148                         1000                     400&lt;BR /&gt;
CVS            08852148                         350                     260&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
for the first two records we need to set flag to Y as they are the same.</description>
      <pubDate>Thu, 09 Dec 2010 13:17:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-flag/m-p/47485#M9827</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-12-09T13:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: create a flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-flag/m-p/47486#M9828</link>
      <description>You could just SORT by price1 and price2 and then use BY processing to assign the flag.  That would work for your direct question.  I suspect that there is more to it that you haven't shared.</description>
      <pubDate>Thu, 09 Dec 2010 15:07:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-flag/m-p/47486#M9828</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2010-12-09T15:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: create a flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-flag/m-p/47487#M9829</link>
      <description>source                 Outlet             price1 price2&lt;BR /&gt;
DDD                    08536148           350 260&lt;BR /&gt;
CVS                    08536148          350 260&lt;BR /&gt;
DDD                    08852148         1000 400&lt;BR /&gt;
CVS                    08852148          350 260&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Yes,&lt;BR /&gt;
I gave the order of the outlets wrongly in the OP.for the same outlets from different sources we need to set a flag if their prices are equal.&lt;BR /&gt;
as in the case of first two records.</description>
      <pubDate>Thu, 09 Dec 2010 15:38:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-flag/m-p/47487#M9829</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-12-09T15:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: create a flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-flag/m-p/47488#M9830</link>
      <description>PROC SORT; BY outlet price1 price2; RUN;&lt;BR /&gt;
&lt;BR /&gt;
DATA;&lt;BR /&gt;
SET;&lt;BR /&gt;
By outlet price1 price2;&lt;BR /&gt;
IF first.price2 &amp;amp; last.price2 THEN Flag='No ';  * unique record;&lt;BR /&gt;
ELSE flag='Yes'; * two or more are the same;&lt;BR /&gt;
RUN;</description>
      <pubDate>Thu, 09 Dec 2010 18:34:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-flag/m-p/47488#M9830</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2010-12-09T18:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: create a flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-flag/m-p/47489#M9831</link>
      <description>It is almost the same with Doc@Duck, except to remove repetition observations.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data temp;&lt;BR /&gt;
 input source $ Outlet : $20. price1 price2;&lt;BR /&gt;
cards;&lt;BR /&gt;
DDD 08536148 350 260&lt;BR /&gt;
CVS 08536148 350 260&lt;BR /&gt;
DDD 08852148 1000 400&lt;BR /&gt;
CVS 08852148 350 260&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=temp nodupkey;&lt;BR /&gt;
 by outlet  price1 price2  source   ;&lt;BR /&gt;
run;&lt;BR /&gt;
data op;&lt;BR /&gt;
 set temp;&lt;BR /&gt;
 By outlet price1 price2 ;&lt;BR /&gt;
 length flag $ 1;&lt;BR /&gt;
 if not (first.price2 and last.price2 ) then  flag='Y';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
If you allow the existence of repetition obs then will need some more code.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Fri, 10 Dec 2010 07:22:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-flag/m-p/47489#M9831</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-12-10T07:22:52Z</dc:date>
    </item>
  </channel>
</rss>

