<?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: %lowcase vs lowcase in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/lowcase-vs-lowcase/m-p/964279#M43264</link>
    <description>&lt;P&gt;It's a contrived example for illustrating a point, of course - basically, so that someone will understand the difference (or occasionally lack thereof) between the two.&amp;nbsp; Here's another:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;** in SAS Studio, this runs in about 1 minute 7 seconds: ;
data test;
do i=1 to 100000000;
    x='frog';
    foundit=(index(lowcase('This is a very long string that 
    contains all sorts of text including FROG and Cats'),x));
    output;
end;
run;

** ...whereas the same thing, using %lowcase, runs in about 8 seconds ;
data test;
do i=1 to 100000000;
    x='frog';
    foundit=(index(%lowcase('This is a very long string that 
    contains all sorts of text including FROG and Cats'),x));
    output;
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 15 Apr 2025 00:40:38 GMT</pubDate>
    <dc:creator>quickbluefish</dc:creator>
    <dc:date>2025-04-15T00:40:38Z</dc:date>
    <item>
      <title>%lowcase vs lowcase</title>
      <link>https://communities.sas.com/t5/New-SAS-User/lowcase-vs-lowcase/m-p/964268#M43258</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample data and code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample_values;
  input letter $;
datalines;
A
B
C
run;

data lower_values;
  set sample_values;
  
  x = %lowcase(letter);
  y = lowcase(letter);
run;

proc print data=lower_values;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The result:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Obs	letter	x	y
1	A	    A	a
2	B	    B	b
3	C	    C	c&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Question 1:&lt;/P&gt;
&lt;P&gt;For the first observation, the %lowcase didn't work, Is it because the %lowcase executed at compile time and the value for LETTER is still missing?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question 2:&lt;BR /&gt;What happened during the 2nd iteration for x?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x = %lowcase(letter);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If %lowcase is executed only once, what would the above line be equivalent to in the 2nd iteration?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 14 Apr 2025 20:57:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/lowcase-vs-lowcase/m-p/964268#M43258</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2025-04-14T20:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: %lowcase vs lowcase</title>
      <link>https://communities.sas.com/t5/New-SAS-User/lowcase-vs-lowcase/m-p/964269#M43259</link>
      <description>&lt;P&gt;%LOWCASE should be used only on macro variables or the results of a macro expression. Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let letter = A;
%put %lowcase(&amp;amp;letter);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LOWCASE should only be used on data set variables, or an expression involving data set variables. Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fake;
    letter='A';
    letter2=lowcase(letter);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use %LOWCASE when you should use LOWCASE, you may not get an error, but you may get unexpected results. So don't mix and match macro functions when you should be using normal functions, and vice versa.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Apr 2025 21:34:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/lowcase-vs-lowcase/m-p/964269#M43259</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-04-14T21:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: %lowcase vs lowcase</title>
      <link>https://communities.sas.com/t5/New-SAS-User/lowcase-vs-lowcase/m-p/964273#M43260</link>
      <description>&lt;P&gt;Yes, I'll just add one bit to what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;said, which is that the only place you'd sensibly use either one and expect to get the same results is if the argument is a string literal as opposed to a variable name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
x=%lowcase("Here is a STRING");
y=lowcase("Here is a STRING");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Apr 2025 22:55:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/lowcase-vs-lowcase/m-p/964273#M43260</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-04-14T22:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: %lowcase vs lowcase</title>
      <link>https://communities.sas.com/t5/New-SAS-User/lowcase-vs-lowcase/m-p/964274#M43261</link>
      <description>&lt;P&gt;Actually %LOWCASE() executed BEFORE compile time.&amp;nbsp; That is because it is not part of the SAS language, but is instead part of the SAS Macro Language.&amp;nbsp; The&amp;nbsp; macro processor pre-processes the text of your program and the results are then sent on to SAS itself to evaluate and run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So this step&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lower_values;
  set sample_values;
  x = %lowcase(LETTER);
  y = lowcase(letter);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will be converted by the macro pre-processor into this step&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lower_values;
  set sample_values;
  x = letter;
  y = lowcase(letter);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which will then be compiled and run by SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Apr 2025 22:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/lowcase-vs-lowcase/m-p/964274#M43261</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-04-14T22:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: %lowcase vs lowcase</title>
      <link>https://communities.sas.com/t5/New-SAS-User/lowcase-vs-lowcase/m-p/964276#M43263</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223320"&gt;@quickbluefish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yes, I'll just add one bit to what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;said, which is that the only place you'd sensibly use either one and expect to get the same results is if the argument is a string literal as opposed to a variable name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
x=%lowcase("Here is a STRING");
y=lowcase("Here is a STRING");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But I said you should not&amp;nbsp; use %LOWCASE with data step variables or data step expressions. Yes, it works the way you said for this particular string, but don't use %LOWCASE here, it is simply &lt;FONT color="#FF0000"&gt;a very bad habit&lt;/FONT&gt; to get into, as there are many cases where it will not produce the same answer.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Apr 2025 23:34:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/lowcase-vs-lowcase/m-p/964276#M43263</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-04-14T23:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: %lowcase vs lowcase</title>
      <link>https://communities.sas.com/t5/New-SAS-User/lowcase-vs-lowcase/m-p/964279#M43264</link>
      <description>&lt;P&gt;It's a contrived example for illustrating a point, of course - basically, so that someone will understand the difference (or occasionally lack thereof) between the two.&amp;nbsp; Here's another:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;** in SAS Studio, this runs in about 1 minute 7 seconds: ;
data test;
do i=1 to 100000000;
    x='frog';
    foundit=(index(lowcase('This is a very long string that 
    contains all sorts of text including FROG and Cats'),x));
    output;
end;
run;

** ...whereas the same thing, using %lowcase, runs in about 8 seconds ;
data test;
do i=1 to 100000000;
    x='frog';
    foundit=(index(%lowcase('This is a very long string that 
    contains all sorts of text including FROG and Cats'),x));
    output;
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Apr 2025 00:40:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/lowcase-vs-lowcase/m-p/964279#M43264</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-04-15T00:40:38Z</dc:date>
    </item>
  </channel>
</rss>

