<?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: %LET macro statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484076#M287028</link>
    <description>&lt;P&gt;This does what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TWO;
  Y='2';
run;
%let x  =10;
%let var=Y;
data ONE;
  set TWO;
  Z=&amp;amp;var.||"*&amp;amp;x";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 05 Aug 2018 00:08:55 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2018-08-05T00:08:55Z</dc:date>
    <item>
      <title>%LET macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484055#M287025</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data two;
y='2';
run;
%let x=10;
%let var=y;
data one;
set two (keep=&amp;amp;var);
z=&amp;amp;var*&amp;amp;x;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;As I know, macro variable can be defined with %let statement, and everything is text in macro variable. So in the above code, variable z returns the value should by text value y multiples text value 10, but actually returns the numeric value 20.&lt;/P&gt;&lt;P&gt;I didn't see any function above &amp;nbsp;that can convert character value to numeric value.&lt;/P&gt;&lt;P&gt;Anyone can explain it for me please?&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Aug 2018 19:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484055#M287025</guid>
      <dc:creator>Karen_sas11</dc:creator>
      <dc:date>2018-08-04T19:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: %LET macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484058#M287026</link>
      <description>&lt;P&gt;When SAS finds a character variable in a place where a numeric value is expected, it makes an automatic typecast. You will get a NOTE in the log about this, and further NOTEs if the contents of the character variable cannot be converted.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Aug 2018 20:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484058#M287026</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-04T20:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: %LET macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484063#M287027</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/207067"&gt;@Karen_sas11&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data two;
y='2';
run;
%let x=10;
%let var=y;
data one;
set two (keep=&amp;amp;var);
z=&amp;amp;var*&amp;amp;x;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;As I know, macro variable can be defined with %let statement, and everything is text in macro variable. So in the above code, variable z returns the value should by text value y multiples text value 10, but actually returns the numeric value 20.&lt;/P&gt;
&lt;P&gt;I didn't see any function above &amp;nbsp;that can convert character value to numeric value.&lt;/P&gt;
&lt;P&gt;Anyone can explain it for me please?&lt;/P&gt;
&lt;P&gt;Many thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not quite.&amp;nbsp; The macro processor will replace the references to the macro variables by their (text) values and then the resulting CODE (&lt;EM&gt;which is of course always text&lt;/EM&gt;) is run by SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you told SAS to run this data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
set two (keep=y);
z=y*10;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So you can see that your SAS code is asking SAS to multiple Y times the constant value 10.&amp;nbsp; Since Y is a character variable SAS will have to convert its values to a number first in order to do that.&amp;nbsp; The SAS log will show you that.&lt;/P&gt;
&lt;PRE&gt;436  data one;
437  set two (keep=&amp;amp;var);
438  z=&amp;amp;var*&amp;amp;x;
439  run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      438:1
NOTE: There were 1 observations read from the data set WORK.TWO.
NOTE: The data set WORK.ONE has 1 observations and 2 variables.&lt;/PRE&gt;</description>
      <pubDate>Sat, 04 Aug 2018 21:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484063#M287027</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-04T21:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: %LET macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484076#M287028</link>
      <description>&lt;P&gt;This does what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TWO;
  Y='2';
run;
%let x  =10;
%let var=Y;
data ONE;
  set TWO;
  Z=&amp;amp;var.||"*&amp;amp;x";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 00:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484076#M287028</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-08-05T00:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: %LET macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484082#M287029</link>
      <description>&lt;P&gt;Thank you Kurt, I didn't really realize that there is a note in the log about this. I went back the log, and there was.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 01:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484082#M287029</guid>
      <dc:creator>Karen_sas11</dc:creator>
      <dc:date>2018-08-05T01:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: %LET macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484083#M287030</link>
      <description>&lt;P&gt;Thanks Tom, now I got it.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 01:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484083#M287030</guid>
      <dc:creator>Karen_sas11</dc:creator>
      <dc:date>2018-08-05T01:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: %LET macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484085#M287031</link>
      <description>&lt;P&gt;Thahks Christ, is a period necessary in the defination of Z?&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 01:59:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484085#M287031</guid>
      <dc:creator>Karen_sas11</dc:creator>
      <dc:date>2018-08-05T01:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: %LET macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484087#M287032</link>
      <description>&lt;P&gt;Try it.&lt;/P&gt;
&lt;P&gt;You'll see that&amp;nbsp; &lt;FONT face="courier new,courier"&gt;Z.=&amp;nbsp;&lt;/FONT&gt;&amp;nbsp; is invalid syntax.&lt;/P&gt;
&lt;P&gt;Periods can be used only to mark the end of macro variable names. Not for data set variables.&lt;/P&gt;
&lt;P&gt;Since your understanding of the SAS language seems so basic, I would strongly suggest that you do not touch the (much more finicky) macro language for now. I'll only create headaches for yourself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 02:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484087#M287032</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-08-05T02:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: %LET macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484108#M287033</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/207067"&gt;@Karen_sas11&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you Kurt, I didn't really realize that there is a note in the log about this. I went back the log, and there was.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Maxim 2. Always read the log, even if a piece of code (seemingly) works.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 07:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484108#M287033</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-05T07:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: %LET macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484152#M287034</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;: I think Karen referred to the period you used after "&amp;amp;var" whereas she had omitted the period in her own code.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/207067"&gt;@Karen_sas11&lt;/a&gt;: In this case the answer is: No, the period is just optional. It would be necessary if&amp;nbsp;&lt;SPAN&gt;what follows it could be interpreted as the macro variable name's continuation (e.g. &lt;FONT face="courier new,courier"&gt;&amp;amp;var.max&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;&amp;amp;var.1&lt;/FONT&gt;) or was itself a period (e.g. &lt;FONT face="courier new,courier"&gt;&amp;amp;var..sum&lt;/FONT&gt;).&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 12:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484152#M287034</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-08-05T12:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: %LET macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484161#M287035</link>
      <description>&lt;P&gt;&amp;nbsp;Thanks Freelance, that's what I am asking.&lt;/P&gt;&lt;P&gt;So far I know the period is frequently used in the alias that refer to the source table in SQL , &amp;nbsp;two-dimension naming, and format/informat, &amp;nbsp;I think.....are they the main uses of a period?&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 15:14:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484161#M287035</guid>
      <dc:creator>Karen_sas11</dc:creator>
      <dc:date>2018-08-05T15:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: %LET macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484173#M287036</link>
      <description>&lt;P&gt;Yes, these are typical occasions where the period is required. But all these are cases where an adjacent period with another meaning makes the (additional) period necessary.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 18:47:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484173#M287036</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-08-05T18:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: %LET macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484505#M287037</link>
      <description>&lt;P&gt;OK，thanks。&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2018 19:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LET-macro-statement/m-p/484505#M287037</guid>
      <dc:creator>Karen_sas11</dc:creator>
      <dc:date>2018-08-06T19:35:58Z</dc:date>
    </item>
  </channel>
</rss>

