<?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: MACRO HELP in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79065#M22788</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;karun wrote:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Also the code doenot give me any output.neither any error after i run it&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;We need to see your code, and the related parts of the SASLOG.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Sep 2012 14:15:01 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2012-09-27T14:15:01Z</dc:date>
    <item>
      <title>MACRO HELP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79061#M22784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%macro freqs(want=,var=,have=,label=);&lt;/P&gt;&lt;P&gt;data &amp;amp;want(RENAME=(&amp;amp;var=PARAM));&lt;/P&gt;&lt;P&gt;length label$150 &amp;amp;var$100 count percent 8.;&lt;/P&gt;&lt;P&gt;set $have;&lt;/P&gt;&lt;P&gt;if _n_= 1 then &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;label= "&amp;amp;label" ;else label=" ";&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Total=0+count;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*if quotes necesarry while referencing labels ie label="AGE"*/&lt;/P&gt;&lt;P&gt;%freqs(want=age_1,var=Age,have=Age_freqs,label=&lt;STRONG&gt;AGE&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi in the macro above can the variable name be similar to the macro reference?&lt;/P&gt;&lt;P&gt;i mean&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;label= "&amp;amp;label" ;else label=" ";&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Also should the AGE be in quotes when referencing????????since its a lablel&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 13:26:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79061#M22784</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2012-09-27T13:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO HELP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79062#M22785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;karun,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might be better-served by using just a single macro variable:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro freqs (var=);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; data &amp;amp;var._1 (rename=(&amp;amp;var=PARAM));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length ...;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_=1 then label="%upcase(&amp;amp;var)";&amp;nbsp; else label=" ";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; total = count;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%mend freqs;&lt;/P&gt;&lt;P&gt;%freqs (var=Age)&lt;/P&gt;&lt;P&gt;It would become important to use initial caps (Age) when calling the macro.&amp;nbsp; I would guess this makes the macro much easier to read and maintain.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The question about quotes makes sense in context only.&amp;nbsp; What should the generated SAS code look like?&amp;nbsp; If the SAS program requires quotes, then use quotes.&amp;nbsp; Macro language isn't relevant to the question, except that macro language must generate the accurate SAS program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 13:36:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79062#M22785</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-09-27T13:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO HELP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79063#M22786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Astounding,&lt;/P&gt;&lt;P&gt;Thanks for the response and sorry for the delay.&lt;/P&gt;&lt;P&gt;each time the want and have changes and so i included them in the referencing.&lt;/P&gt;&lt;P&gt;Also my second question was if i can have&lt;/P&gt;&lt;P&gt;label=&amp;amp;label (variable name is same like the refencing variable)..........should it be different??????&lt;/P&gt;&lt;P&gt;&amp;amp;label being referenced to may be apple.........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 14:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79063#M22786</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2012-09-27T14:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO HELP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79064#M22787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Also the code doenot give me any output.neither any error after i run it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 14:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79064#M22787</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2012-09-27T14:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO HELP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79065#M22788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;karun wrote:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Also the code doenot give me any output.neither any error after i run it&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;We need to see your code, and the related parts of the SASLOG.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 14:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79065#M22788</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2012-09-27T14:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO HELP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79066#M22789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;karun,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is perfectly fine to give LABEL a value of the name of a variable.&amp;nbsp; I'm guessing here, but I would imagine you intend to use LABEL later, as part of an output data set from PROC FREQ.&amp;nbsp; There might be other ways to extend your macro, and have macro language pick out that information instead of creating LABEL.&amp;nbsp; But your approach would work (and there's a lot to be said for any program that works!).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As was stated, if you are not getting output you would have to show us a little more for us to figure out what is happening.&amp;nbsp; Here is one possibility that would give you no output at all.&amp;nbsp; Suppose you defined your macro with default parameters, so the macro could be called using default values for all parameters.&amp;nbsp; In that case, this is not enough to cause the macro to start executing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%freqs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In an interactive environment, SAS wouldn't know that your call to the macro was complete.&amp;nbsp; You would at least have to add:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%freqs ()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That way, SAS knows you don't intend to overwrite any of the default parameters.&amp;nbsp; Of course, there are a lot of other possibilities so show us the code and we'll figure it out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 14:28:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79066#M22789</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-09-27T14:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO HELP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79067#M22790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much for your detailed explanation of the topic.&lt;/P&gt;&lt;P&gt;I figured out I was running the program without the &lt;STRONG&gt;%mend;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Dont get angry on me...&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thanks&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 15:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79067#M22790</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2012-09-27T15:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO HELP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79068#M22791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Astounding,&lt;/P&gt;&lt;P&gt;In the code below&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %upcase and then the macrovariable &lt;STRONG&gt;in braces&lt;/STRONG&gt; would give uppercase of the var???????&lt;/P&gt;&lt;P&gt;If so What are the other options helpful like this one???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if _n_=1 then label="&lt;STRONG&gt;%upcase&lt;/STRONG&gt;(&amp;amp;var)";&amp;nbsp; else label=" ";&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 15:20:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79068#M22791</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2012-09-27T15:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO HELP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79069#M22792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No problem.&amp;nbsp; Hard to get angry for doing something that we all have done at one point or another.&amp;nbsp; &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even harder to get angry when you solved the problem and we don't have to do anything more.&amp;nbsp; :smileylaugh:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 15:21:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79069#M22792</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-09-27T15:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO HELP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79070#M22793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;label="%upcase(&amp;amp;var)";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is giving the uppercase of the value assigned to the macro variable &amp;amp;VAR.&amp;nbsp; There are very, very few additional options as macro language does not contain many functions.&amp;nbsp; However, two items are worthy of note.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. The DATA step contains many functions.&amp;nbsp; This would be a reasonable alternative:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;label = upcase("&amp;amp;var");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The DATA step contains hundreds of functions (you'll have to do your own work to look them up).&amp;nbsp; In some cases, however, using a DATA step function to create a new variable assigns a length to the new variable that is longer than what you would assume.&amp;nbsp; You'll have to look at the function documentation and test it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Macro language allows access to most all DATA step functions, but the programming gets a little involved to make it happen.&amp;nbsp; The macro function %SYSFUNC is used to access functions that are not built into macro language including (most) DATA step functions.&amp;nbsp; Too many details to go into here, since it's not a topic that you'll need yet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 15:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79070#M22793</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-09-27T15:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO HELP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79071#M22794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Astounding,&lt;/P&gt;&lt;P&gt;Do u mean both the steps below gives the same result????????irrespective of the position of the braces????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;label="%upcase(&amp;amp;var)";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;label = upcase("&amp;amp;var");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 15:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79071#M22794</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2012-09-27T15:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO HELP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79072#M22795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, the results are identical.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try it for yourself.&amp;nbsp; Use two variables, LABEL1 and LABEL2.&amp;nbsp; Then run a PROC PRINT and a PROC CONTENTS.&amp;nbsp; For the first statement, you have to picture how SAS would handle this statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;label="AGE";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's what SAS sees, after macro language gets done interpreting %upcase(&amp;amp;var).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 17:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79072#M22795</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-09-27T17:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO HELP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79073#M22796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Thanks so much..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Great help. I shall try it myself too...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 17:28:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MACRO-HELP/m-p/79073#M22796</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2012-09-27T17:28:33Z</dc:date>
    </item>
  </channel>
</rss>

