<?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 values based specific values present in another variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-values-based-specific-values-present-in-another-variable/m-p/625771#M184490</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data one;
input id par $ ady;
datalines;
1 a 3
1 a 6
1 a 9
2 a 6
3 a 3
3 a 4
4 a 4
4 a 8
5 a 7
5 a 10
6 a 5
6 a 12
;

data want;
 set one;
 by id par;
 length want $3;
 retain want;
 if first.par then want='no';
 if  ady in (3,6,9,12,15,18,21,24) then want='yes';
 if last.par;
 keep id par want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 19 Feb 2020 03:14:52 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-02-19T03:14:52Z</dc:date>
    <item>
      <title>How to values based specific values present in another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-values-based-specific-values-present-in-another-variable/m-p/625768#M184488</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;data one;
input id par $ ady;
datalines;
1 a 3
1 a 6
1 a 9
2 a 6
3 a 3
3 a 4
4 a 4&lt;BR /&gt;4 a 8
5 a 7&lt;BR /&gt;5 a 10
6 a 5&lt;BR /&gt;6 a 12
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Dear&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a variable '&lt;FONT color="#FF6600"&gt;want'&amp;nbsp;&amp;nbsp;&lt;FONT color="#000000"&gt;based on 'ady' variable values.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;FONT color="#000000"&gt;If ady contains at least one of the values (3,6,9,12 or 15,18,21,24) in any record by &lt;FONT color="#FF0000"&gt;id and par&lt;/FONT&gt;&amp;nbsp; &amp;nbsp;then for the subject&amp;nbsp; want='Yes';&amp;nbsp; else want='No'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;FONT color="#000000"&gt;output needed;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;FONT color="#000000"&gt;id&amp;nbsp; &amp;nbsp; want&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;FONT color="#000000"&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;FONT color="#000000"&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;FONT color="#000000"&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; Yes&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;FONT color="#000000"&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; No&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;FONT color="#000000"&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; No&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;FONT color="#000000"&gt;6&amp;nbsp; &amp;nbsp; &amp;nbsp; Yes&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;FONT color="#000000"&gt;for id= 4 and 5&amp;nbsp; &amp;nbsp; the subjects do not have records with values&amp;nbsp; (3,6,9,12 or 15). So want='No'.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;FONT color="#000000"&gt;Please suggest. Thank you&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 03:00:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-values-based-specific-values-present-in-another-variable/m-p/625768#M184488</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2020-02-19T03:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to values based specific values present in another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-values-based-specific-values-present-in-another-variable/m-p/625771#M184490</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data one;
input id par $ ady;
datalines;
1 a 3
1 a 6
1 a 9
2 a 6
3 a 3
3 a 4
4 a 4
4 a 8
5 a 7
5 a 10
6 a 5
6 a 12
;

data want;
 set one;
 by id par;
 length want $3;
 retain want;
 if first.par then want='no';
 if  ady in (3,6,9,12,15,18,21,24) then want='yes';
 if last.par;
 keep id par want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Feb 2020 03:14:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-values-based-specific-values-present-in-another-variable/m-p/625771#M184490</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-19T03:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to values based specific values present in another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-values-based-specific-values-present-in-another-variable/m-p/625774#M184491</link>
      <description>&lt;P&gt;HI Thank you very much for the help. I have another question which i need help. Currently in my data, I see&amp;nbsp; 3 interval up to 24.&amp;nbsp; If in my data contains any subject with greater than 24(for example, 39), instead of me again updating my code, is there any way i can make my code efficient. Please suggest solution&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 03:39:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-values-based-specific-values-present-in-another-variable/m-p/625774#M184491</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2020-02-19T03:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to values based specific values present in another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-values-based-specific-values-present-in-another-variable/m-p/625777#M184492</link>
      <description>&lt;P&gt;You apparently desire want='yes' for any ID/PAR that has at least one record with ADY as a multiple of 3.&amp;nbsp; I.e. ADY divided by 3 has a remainder of zero.&amp;nbsp; In other words&amp;nbsp; ADY modulo 3 = 0, which in SAS language is&amp;nbsp; MOD(ADY,3)=0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input id par $ ady;
datalines;
1 a 3
1 a 6
1 a 9
2 a 6
3 a 3
3 a 4
4 a 4
4 a 8
5 a 7
5 a 10
6 a 5
6 a 12
;

data want (keep=id par want);
  set one (where=(mod(ady,3)=0) in=inw)
      one (where=(mod(ady,3)^=0)) ;
  by id par;
  if first.par;
  if inw then want='Yes';
  else want='No';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This program reads dataset ONE in two "substreams" of the SET statement.&amp;nbsp; One stream reads in only records with ADY divisible by 3.&amp;nbsp; The other reads all the other records. &amp;nbsp; The SET statement with a "by id par" interleaves these two streams such that any qualifying ADY is at the start of each ID/PAR group.&amp;nbsp; So all you have to do is test the first incoming record for each ID/PAR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 04:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-values-based-specific-values-present-in-another-variable/m-p/625777#M184492</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-02-19T04:11:00Z</dc:date>
    </item>
  </channel>
</rss>

