<?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: Count with left in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-with-left/m-p/103486#M21595</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are two ways to make the macro variables global:&lt;/P&gt;&lt;P&gt;1) Remove macro definition completely.&lt;/P&gt;&lt;P&gt;2) Using %global statement &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise they are local, they still can be printed out within your macro though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Jun 2013 03:24:41 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2013-06-12T03:24:41Z</dc:date>
    <item>
      <title>Count with left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-with-left/m-p/103485#M21594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I am trying to create macro variables using proc sql within a macro.But the code does not work. its pretty simple code but I do not understand why its not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input var;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;12&lt;/P&gt;&lt;P&gt;34&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;79&lt;/P&gt;&lt;P&gt;84&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%macro m1;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;select count(var) into :cnt from have ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;Proc sql noprint;&lt;/P&gt;&lt;P&gt;select var into :val1 - :val%left(&amp;amp;cnt) from have;&lt;/P&gt;&lt;P&gt;Quit;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%m1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;val1 &amp;amp;val2 &amp;amp;val3 &amp;amp;val4 &amp;amp;val5;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jun 2013 03:07:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-with-left/m-p/103485#M21594</guid>
      <dc:creator>forumsguy</dc:creator>
      <dc:date>2013-06-12T03:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Count with left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-with-left/m-p/103486#M21595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are two ways to make the macro variables global:&lt;/P&gt;&lt;P&gt;1) Remove macro definition completely.&lt;/P&gt;&lt;P&gt;2) Using %global statement &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise they are local, they still can be printed out within your macro though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jun 2013 03:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-with-left/m-p/103486#M21595</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-06-12T03:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: Count with left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-with-left/m-p/103487#M21596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what is the error your getting? I think you cannot use %left function . What you can do %let cnt=%trim(&amp;amp;cnt) before the second query.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jun 2013 06:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-with-left/m-p/103487#M21596</guid>
      <dc:creator>manojinpec</dc:creator>
      <dc:date>2013-06-12T06:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Count with left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-with-left/m-p/103488#M21597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is no problem with the %left. This is as Haikuo already stated a problem with local vs global macro variables.&lt;BR /&gt;Removing the macro definition seems to the most reasonable action, having the code wrapped up inside a macro does not add anything... &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jun 2013 07:11:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-with-left/m-p/103488#M21597</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-06-12T07:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Count with left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-with-left/m-p/103489#M21598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;Yes ,You Have to mention %global in your macro as said by &lt;A __default_attr="119192" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;or else you have to create all the macro variables&amp;nbsp; with dummy values before the macro.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;like&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="color: navy; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; have;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; var;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;datalines&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% #ffffc0; font-size: 10pt; font-family: 'Courier New';"&gt;12&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% #ffffc0; font-size: 10pt; font-family: 'Courier New';"&gt;34&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% #ffffc0; font-size: 10pt; font-family: 'Courier New';"&gt;8&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% #ffffc0; font-size: 10pt; font-family: 'Courier New';"&gt;79&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% #ffffc0; font-size: 10pt; font-family: 'Courier New';"&gt;84&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="color: navy; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;run&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; Val1=0;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; Val2=0;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; Val3=0;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; Val4=0;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; Val5=0;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="color: navy; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;%macro&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; &lt;EM&gt;m1&lt;/EM&gt;;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;proc sql noprint;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;select count(var) into :cnt from have ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;Proc sql noprint;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;select var into :val1 - :val%&lt;EM&gt;left&lt;/EM&gt;(&amp;amp;cnt) from have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;Quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="color: navy; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;%mend&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt;;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;%&lt;EM&gt;m1&lt;/EM&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: none repeat scroll 0% 0% white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: none repeat scroll 0% 0% white;"&gt; &amp;amp;val1 &amp;amp;val2 &amp;amp;val3 &amp;amp;val4 &amp;amp;val5;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;But i always prefer to use&amp;nbsp; %Global.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; background: none repeat scroll 0% 0% white; font-size: 10pt; font-family: 'Courier New';"&gt;Regards.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;STRONG&gt;Sanjeev.K&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jun 2013 09:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-with-left/m-p/103489#M21598</guid>
      <dc:creator>kuridisanjeev</dc:creator>
      <dc:date>2013-06-12T09:59:22Z</dc:date>
    </item>
  </channel>
</rss>

