<?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: UpcaseLowcase in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/UpcaseLowcase/m-p/455808#M115362</link>
    <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I agree with a DO loop, I'm not sure you need an ARRAY, since the TRANSLATE function will work for you. I did not consider 'y' to be a vowel for this example. Also, I did NOT overwrite the original values because I wanted to show my work in progress (TmpStr, NewCity and NewTeam):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="upcase_lowcase.png" style="width: 595px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/19992i0D4D313373E1A74C/image-size/large?v=v2&amp;amp;px=999" role="button" title="upcase_lowcase.png" alt="upcase_lowcase.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here's the code I used:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sports;
  length City NewCity $15 Team NewTeam $12 TmpStr  $30 uchar $1;
  infile datalines dlm=',' dsd;
  input @1 City $ year Team $;
  TmpStr=upcase(catx('~',City,Team));
  do ck = 'a', 'e', 'i', 'o', 'u';
    uchar = upcase(ck);
    TmpStr = translate(TmpStr,ck,uchar);
  end;
  NewCity = scan(TmpStr,1,'~');
  NewTeam = scan(TmpStr,2,'~');
return;
datalines;
Baltimore, 2012, Ravens
Cincinnati, 2012, Bengals
Cleveland, 2012, Browns
Pittsburgh, 2012, Steelers
Chicago, 2012, Bears
Detroit, 2012, Lions
Green Bay, 2012, Packers
;
run;
  
proc print data=sports;
var City NewCity year Team NewTeam TmpStr;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 20 Apr 2018 02:33:48 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2018-04-20T02:33:48Z</dc:date>
    <item>
      <title>UpcaseLowcase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/UpcaseLowcase/m-p/455796#M115359</link>
      <description>&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;I have been trying to figure it out how to solve this question for two days but no luck yet.&amp;nbsp; Hope you can help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Q)&amp;nbsp; Convert all consonants in the values for the&amp;nbsp;&lt;STRONG&gt;City&amp;nbsp;&lt;/STRONG&gt;and&amp;nbsp;&lt;STRONG&gt;Team&amp;nbsp;&lt;/STRONG&gt;variables to uppercase letters and all vowels in the values for the&amp;nbsp;&lt;STRONG&gt;City&amp;nbsp;&lt;/STRONG&gt;and&amp;nbsp;&lt;STRONG&gt;Team&amp;nbsp;&lt;/STRONG&gt;variables to lowercase letters.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;Note: Overwrite the original values with the new values&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;SPAN&gt;Refer the detail to the attachment.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;infile ' /home/coccus030/sasuser.v94/nfldata2.txt' firstobs=2;&lt;BR /&gt;*/ &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/162406"&gt;@20&lt;/a&gt; to indicate SAS to read at 20&amp;nbsp; city and year are too close to each other;&lt;BR /&gt;input City &amp;amp; $16. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/162406"&gt;@20&lt;/a&gt; Year Team $;&lt;BR /&gt;Spacec = city;&lt;BR /&gt;if index (strip(city),'') &amp;gt;0 then spacec =1;&lt;BR /&gt;else spacec = 0;&lt;BR /&gt;Spacet = Team;&lt;BR /&gt;if index (strip(team),'')&amp;gt;0 then spacet = 1;&lt;BR /&gt;else Spacet = 0;&lt;BR /&gt;Numbert = team;&lt;BR /&gt;*anydigit look for number;&lt;BR /&gt;if anydigit (team) then numbert =1;&lt;BR /&gt;else numbert = 0;&lt;BR /&gt;CityTeam = catx('-',city,team);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;array CTL (3) $ city Team Cityteam;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;do lowcase = 1 to substr('City',2,1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If substr(lowcase(City),2,1) in ('a','e','i','o','u') then CTL (lowcase) = lowcase;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;else CTL (lowcase) = upcase;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;end;&lt;BR /&gt;superbowl = city;&lt;BR /&gt;if team = 'Giants' then superbowl = 'Winner';&lt;BR /&gt;else superbowl = 'not a contender';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Txt&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="_ad_q1"&gt;----+----1----+----2----+----3
Baltimore 2012 Ravens
Cincinnati 2012 Bengals
Cleveland 2012 Browns
Pittsburgh 2012 Steelers
Chicago 2012 Bears
Detroit 2012 Lions
Green Bay 2012 Packers&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 00:47:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/UpcaseLowcase/m-p/455796#M115359</guid>
      <dc:creator>elsalam</dc:creator>
      <dc:date>2018-04-20T00:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: UpcaseLowcase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/UpcaseLowcase/m-p/455808#M115362</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I agree with a DO loop, I'm not sure you need an ARRAY, since the TRANSLATE function will work for you. I did not consider 'y' to be a vowel for this example. Also, I did NOT overwrite the original values because I wanted to show my work in progress (TmpStr, NewCity and NewTeam):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="upcase_lowcase.png" style="width: 595px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/19992i0D4D313373E1A74C/image-size/large?v=v2&amp;amp;px=999" role="button" title="upcase_lowcase.png" alt="upcase_lowcase.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here's the code I used:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sports;
  length City NewCity $15 Team NewTeam $12 TmpStr  $30 uchar $1;
  infile datalines dlm=',' dsd;
  input @1 City $ year Team $;
  TmpStr=upcase(catx('~',City,Team));
  do ck = 'a', 'e', 'i', 'o', 'u';
    uchar = upcase(ck);
    TmpStr = translate(TmpStr,ck,uchar);
  end;
  NewCity = scan(TmpStr,1,'~');
  NewTeam = scan(TmpStr,2,'~');
return;
datalines;
Baltimore, 2012, Ravens
Cincinnati, 2012, Bengals
Cleveland, 2012, Browns
Pittsburgh, 2012, Steelers
Chicago, 2012, Bears
Detroit, 2012, Lions
Green Bay, 2012, Packers
;
run;
  
proc print data=sports;
var City NewCity year Team NewTeam TmpStr;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Apr 2018 02:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/UpcaseLowcase/m-p/455808#M115362</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-04-20T02:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: UpcaseLowcase</title>
      <link>https://communities.sas.com/t5/SAS-Programming/UpcaseLowcase/m-p/455829#M115378</link>
      <description>&lt;P&gt;I would do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sports;
  length City $15 Team $12;
  infile datalines dlm=',' dsd;
  input @1 City $ year Team $;
from = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
to =   "aBCDeFGHiJKLMNoPQRSTuVWXyZ";
city = translate(upcase(city),to,from);
team = translate(upcase(team),to,from);
drop from to;
datalines;
Baltimore, 2012, Ravens
Cincinnati, 2012, Bengals
Cleveland, 2012, Browns
Pittsburgh, 2012, Steelers
Chicago, 2012, Bears
Detroit, 2012, Lions
Green Bay, 2012, Packers
;

proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Apr 2018 04:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/UpcaseLowcase/m-p/455829#M115378</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-04-20T04:59:23Z</dc:date>
    </item>
  </channel>
</rss>

