<?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 keep evvery 3 rd observation of sex variable keep in small letter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584299#M166388</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if mod(_n_,3)=0 then sex=lowcase(sex);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 27 Aug 2019 16:52:22 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-08-27T16:52:22Z</dc:date>
    <item>
      <title>how to keep evvery 3 rd observation of sex variable keep in small letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584298#M166387</link>
      <description>&lt;P&gt;&amp;nbsp;i have sashelp.class&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 Alfred M 14 69.0 112.5&lt;BR /&gt;2 Alice F 13 56.5 84.0&lt;BR /&gt;3 Barbara F 13 65.3 98.0&lt;BR /&gt;4 Carol F 14 62.8 102.5&lt;BR /&gt;5 Henry M 14 63.5 102.5&lt;BR /&gt;6 James M 12 57.3 83.0&lt;BR /&gt;7 Jane F 12 59.8 84.5&lt;BR /&gt;8 Janet F 15 62.5 112.5&lt;BR /&gt;9 Jeffrey M 13 62.5 84.0&lt;BR /&gt;10 John M 12 59.0 99.5&lt;BR /&gt;11 Joyce F 11 51.3 50.5&lt;BR /&gt;12 Judy F 14 64.3 90.0&lt;BR /&gt;13 Louise F 12 56.3 77.0&lt;BR /&gt;14 Mary F 15 66.5 112.0&lt;BR /&gt;15 Philip M 16 72.0 150.0&lt;BR /&gt;16 Robert M 12 64.8 128.0&amp;nbsp;&lt;BR /&gt;17 Ronald M 15 67.0 133.0&lt;BR /&gt;18 Thomas M 11 57.5 85.0&lt;BR /&gt;19 William M 15 66.5 112.0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but to keep every 3rd record sex variable keep in samll letter like see below dataset&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 Alfred M 14 69.0 112.5&lt;BR /&gt;2 Alice F 13 56.5 84.0&lt;BR /&gt;3 Barbara F 13 65.3 98.0&lt;BR /&gt;4 Carol f 14 62.8 102.5&lt;BR /&gt;5 Henry m 14 63.5 102.5&lt;BR /&gt;6 James m 12 57.3 83.0&lt;BR /&gt;7 Jane F 12 59.8 84.5&lt;BR /&gt;8 Janet F 15 62.5 112.5&lt;BR /&gt;9 Jeffrey M 13 62.5 84.0&lt;BR /&gt;10 John m12 59.0 99.5&lt;BR /&gt;11 Joyce f 11 51.3 50.5&lt;BR /&gt;12 Judy f 14 64.3 90.0&lt;BR /&gt;13 Louise F 12 56.3 77.0&lt;BR /&gt;14 Mary F 15 66.5 112.0&lt;BR /&gt;15 Philip M 16 72.0 150.0&lt;BR /&gt;16 Robert m 12 64.8 128.0&lt;BR /&gt;17 Ronald m 15 67.0 133.0&lt;BR /&gt;18 Thomas m 11 57.5 85.0&lt;BR /&gt;19 William M 15 66.5 112.0&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 16:47:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584298#M166387</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2019-08-27T16:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep evvery 3 rd observation of sex variable keep in small letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584299#M166388</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if mod(_n_,3)=0 then sex=lowcase(sex);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Aug 2019 16:52:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584299#M166388</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-27T16:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep evvery 3 rd observation of sex variable keep in small letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584302#M166390</link>
      <description>Not like that 1,2,3 observations capital&lt;BR /&gt;4,5,6 observations lowcase like that&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Aug 2019 16:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584302#M166390</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2019-08-27T16:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep evvery 3 rd observation of sex variable keep in small letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584304#M166391</link>
      <description>&lt;P&gt;Okay, got it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
group+1;
do i=1 to 3 until(z);
set sashelp.class end=z;
if mod(group,2)=0 then sex=lowcase(sex);
output;
end;
drop group i;;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Aug 2019 17:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584304#M166391</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-27T17:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep evvery 3 rd observation of sex variable keep in small letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584306#M166392</link>
      <description>This should also work:    if mod(ceil( _N_ / 3 ), 2) = 0 then sex = lowcase(sex);</description>
      <pubDate>Tue, 27 Aug 2019 17:07:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584306#M166392</guid>
      <dc:creator>JosvanderVelden</dc:creator>
      <dc:date>2019-08-27T17:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep evvery 3 rd observation of sex variable keep in small letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584308#M166393</link>
      <description>&lt;P&gt;Very nice!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 17:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584308#M166393</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-27T17:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep evvery 3 rd observation of sex variable keep in small letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584310#M166394</link>
      <description>&lt;P&gt;Or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if mod(_n_+2,6)&amp;lt;3 then sex=lowcase(sex);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;: Just to explain&amp;nbsp;how to derive the IF condition systematically:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Note that your pattern ("&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;AAAaaa&lt;/STRONG&gt;AAAaaa...&lt;/FONT&gt;") has a period of length &lt;STRONG&gt;6&lt;/STRONG&gt;.&lt;BR /&gt;So, the 6 elements of the pattern in one period &lt;EM&gt;must&lt;/EM&gt; correspond (one-to-one) to the values of &lt;FONT face="courier new,courier"&gt;mod(_n_,6)&lt;/FONT&gt;:&lt;BR /&gt;
&lt;PRE&gt;A A A a a a
1 2 3 4 5 0&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;This already gives you a first solution: &lt;FONT face="courier new,courier"&gt;mod(_n_,6) in (0,4,5)&lt;/FONT&gt;.&lt;/LI&gt;
&lt;LI&gt;When you shift the pattern by two places to the right (remembering that the period "1 2 3 4 5 0" repeats as well), the lowercase letters correspond to 0, 1, 2 (rather than 4, 5, 0), which allows for shorter code:&amp;nbsp;&lt;FONT face="courier new,courier"&gt;mod(_n_&lt;STRONG&gt;+2&lt;/STRONG&gt;,6)&lt;STRONG&gt;&lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;BR /&gt;Or you could shift it by one place to the left, leading to the equally short alternative solution &lt;FONT face="courier new,courier"&gt;mod(_n_&lt;STRONG&gt;-1&lt;/STRONG&gt;,6)&lt;STRONG&gt;&amp;gt;2&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 27 Aug 2019 18:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584310#M166394</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-08-27T18:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep evvery 3 rd observation of sex variable keep in small letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584311#M166395</link>
      <description>&lt;P&gt;Play around until you get a function that works.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data check;
  do n=1 to 10;
    div3 = int((n-1)/3);
    mod2 = mod(div3,2);
    output;
  end;
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use it with the _N_ automatic variable.&lt;/P&gt;
&lt;P&gt;Let's use NAME instead of SEX to see the effect of both UPCASE() and LOWCASE().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set sashelp.class ;
  if mod(int((_n_-1)/3),2) then name=lowcase(name);
  else name=upcase(name);
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    Name       Sex    Age    Height    Weight

  1    ALFRED      M      14     69.0      112.5
  2    ALICE       F      13     56.5       84.0
  3    BARBARA     F      13     65.3       98.0
  4    carol       F      14     62.8      102.5
  5    henry       M      14     63.5      102.5
  6    james       M      12     57.3       83.0
  7    JANE        F      12     59.8       84.5
  8    JANET       F      15     62.5      112.5
  9    JEFFREY     M      13     62.5       84.0
 10    john        M      12     59.0       99.5
 11    joyce       F      11     51.3       50.5
 12    judy        F      14     64.3       90.0
 13    LOUISE      F      12     56.3       77.0
 14    MARY        F      15     66.5      112.0
 15    PHILIP      M      16     72.0      150.0
 16    robert      M      12     64.8      128.0
 17    ronald      M      15     67.0      133.0
 18    thomas      M      11     57.5       85.0
 19    WILLIAM     M      15     66.5      112.0
&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Aug 2019 17:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584311#M166395</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-27T17:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep evvery 3 rd observation of sex variable keep in small letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584423#M166460</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;You don't need GROUP; _N_ is automatically&amp;nbsp;&lt;EM&gt;the&lt;/EM&gt; group:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;                                       
  do _iorc_ = 1 to 3 ;                            
    set sashelp.class ;                           
    if mod (_n_, 2) = 0 then sex = lowcase (sex) ;
    output ;                                      
  end ;                                           
run ;                                             
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I'd eagerly defer to the 1-liner by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3492"&gt;@JosvanderVelden&lt;/a&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;                                                
  set sashelp.class ;                                      
  if not mod (ceil (_n_ / 3), 2) then sex = lowcase (sex) ;
run ;                                                      
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;since it needs no understanding of either the DoW-loop or the true behavior of _N_; just simple integer/modular arithmetic.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 04:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584423#M166460</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-28T04:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep evvery 3 rd observation of sex variable keep in small letter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584522#M166505</link>
      <description>&lt;P&gt;Guru&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp; &amp;nbsp;Good morning, Sharp alert and it is proven now I lack ATD(Attention to detail) both on reading the question thoroughly, to the approach +plus a quantitative push. Hmm, really have to start working on it. Well, a cheeky excuse is I may have to go back to Dunkin and get a refund for my coffee or switch to starbucks. I blame the coffee for (ATD issues) &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 12:13:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-evvery-3-rd-observation-of-sex-variable-keep-in/m-p/584522#M166505</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-28T12:13:13Z</dc:date>
    </item>
  </channel>
</rss>

