<?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: creating flag for repeating values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-flag-for-repeating-values/m-p/679579#M205217</link>
    <description>Thank you! It worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Wed, 26 Aug 2020 19:24:55 GMT</pubDate>
    <dc:creator>sonicview</dc:creator>
    <dc:date>2020-08-26T19:24:55Z</dc:date>
    <item>
      <title>creating flag for repeating values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-flag-for-repeating-values/m-p/679574#M205212</link>
      <description>&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How I can create a flag for repeating value. This is the case. If a subject reappears in the same study for the same drug then no flag. But if the same subject appears in another study for the same drug then flag = "Y" for both studies.&lt;/P&gt;&lt;P&gt;Here is sample data with flag values which I want to derive.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;study&amp;nbsp; &amp;nbsp;subject&amp;nbsp; &amp;nbsp; drug&amp;nbsp; &amp;nbsp;flag&lt;/P&gt;&lt;P&gt;01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D1&amp;nbsp; &amp;nbsp; &amp;nbsp; Y&lt;/P&gt;&lt;P&gt;01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D2&amp;nbsp;&lt;/P&gt;&lt;P&gt;01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D2&lt;/P&gt;&lt;P&gt;01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1004&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D1&lt;/P&gt;&lt;P&gt;02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;&lt;P&gt;02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 19:01:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-flag-for-repeating-values/m-p/679574#M205212</guid>
      <dc:creator>sonicview</dc:creator>
      <dc:date>2020-08-26T19:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: creating flag for repeating values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-flag-for-repeating-values/m-p/679575#M205213</link>
      <description>&lt;P&gt;This code creates a flag that is 1 if the drug comes from two (or more) studies, and 0 otherwise.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table want as select *,count(distinct study)&amp;gt;1 as flag from have
	group by subject,drug order by study,subject,drug;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 19:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-flag-for-repeating-values/m-p/679575#M205213</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-26T19:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: creating flag for repeating values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-flag-for-repeating-values/m-p/679579#M205217</link>
      <description>Thank you! It worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 26 Aug 2020 19:24:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-flag-for-repeating-values/m-p/679579#M205217</guid>
      <dc:creator>sonicview</dc:creator>
      <dc:date>2020-08-26T19:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: creating flag for repeating values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-flag-for-repeating-values/m-p/679581#M205218</link>
      <description>&lt;P&gt;Here's one way - and it also adds a count to indicate how many studies the person was in with that drug.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover;
input study   subject    drug  $ flag $;
cards;
01       1000          D1      Y
01       1001          D2 
01       1001          D2
01       1004          D1
02       1000          D1       Y
02       1001          D7
;;;;

proc sql;
create table want as
select *, count(distinct study) as num_studies, 
	case when calculated num_studies &amp;gt; 1 then 'Y' 
	else " " 
	end as calculated_flag
from have
group by subject, drug
order by study, subject;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/242183"&gt;@sonicview&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How I can create a flag for repeating value. This is the case. If a subject reappears in the same study for the same drug then no flag. But if the same subject appears in another study for the same drug then flag = "Y" for both studies.&lt;/P&gt;
&lt;P&gt;Here is sample data with flag values which I want to derive.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;study&amp;nbsp; &amp;nbsp;subject&amp;nbsp; &amp;nbsp; drug&amp;nbsp; &amp;nbsp;flag&lt;/P&gt;
&lt;P&gt;01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D1&amp;nbsp; &amp;nbsp; &amp;nbsp; Y&lt;/P&gt;
&lt;P&gt;01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D2&lt;/P&gt;
&lt;P&gt;01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1004&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D1&lt;/P&gt;
&lt;P&gt;02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;
&lt;P&gt;02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D7&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 19:29:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-flag-for-repeating-values/m-p/679581#M205218</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-26T19:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: creating flag for repeating values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-flag-for-repeating-values/m-p/679590#M205219</link>
      <description>&lt;P&gt;Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; seems to be in supreme form lately. Kudos!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/242183"&gt;@sonicview&lt;/a&gt;&amp;nbsp; If you are really after Y and ' ', you could use IFC as an extension in Mr Miller's logic-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 create table want as 
 select *,ifc(count(distinct study)&amp;gt;1,'Y',' ') as flag 
 from have
 group by subject,drug 
 order by study,subject,drug;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Aug 2020 19:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-flag-for-repeating-values/m-p/679590#M205219</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-08-26T19:48:31Z</dc:date>
    </item>
  </channel>
</rss>

