<?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: How do I use user defined format inside a SAS macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300208#M270348</link>
    <description>&lt;P&gt;It would be much easier if you came up with a few examples of the output (MEMBER1) and the input (VAR1) that are causing trouble.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error message you got would only occur if you tried to set the length of a numeric to 2.&amp;nbsp; It shouldn't occur with the code that you posted.&amp;nbsp; SAS does not store numerics as digits.&amp;nbsp; SAS uses a totally different format.&amp;nbsp; So lengths of numerics should only be set to less than 8 when you know the range of values, and when the variable takes on only integer values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the case of your program and data, luckily a length of 3 should be long enough to hold all three-digit integers.&amp;nbsp; If you are getting strange values for MEMBER1, you probably have similarly strange values for VAR1.&amp;nbsp; For example, if VAR1 contained 5E678, the INPUT function would read "5E6" and intpret this as scientific notation.&amp;nbsp; The value would be too large to fit into MEMBER1.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Sep 2016 20:13:31 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-09-22T20:13:31Z</dc:date>
    <item>
      <title>How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299863#M270335</link>
      <description>&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;I have created a format like the one below:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;value&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; $test_group&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"23"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"a"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"43"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"b"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"32"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"c"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;other=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"other"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;&lt;STRONG&gt;I want to use the format test_group for a variable inside a macro. The main problem statement is that I have 10 datasets, all having same variables. I want to assign the above format to the variable in&amp;nbsp;all the datasets at once. &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;Here is the macro:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; fmt(table=,var1=group_test);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;set &amp;amp;table;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;length val_fmt &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$10.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;val_fmt = put(&amp;amp;group_test,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$test_group.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;/*group_test is the common variable to all datasets that I want to assign the format */&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; tname(table=a, var1=group_test);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;I get the error format not found.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 15:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299863#M270335</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2016-09-21T15:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299866#M270336</link>
      <description>&lt;P&gt;First verify that you ran the Proc format code and that it created the format okay. (I manage to skip this step about once a month).&lt;/P&gt;
&lt;P&gt;Second run you macro with Options mprint symbolgen; and post the resulting log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 15:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299866#M270336</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-21T15:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299867#M270337</link>
      <description>&lt;P&gt;If you want to be able to assign a user-defined format inside a macro, you first have to be able to assign a user-defined format outside of a macro.&amp;nbsp; Pick one of your data sets, and get a program that does what you want.&amp;nbsp; Then you can worry about how to add macro language to apply those steps to 10 data sets.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 15:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299867#M270337</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-21T15:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299869#M270338</link>
      <description>&lt;P&gt;I did apply the format to a dataset.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test(keep=var1 val_fmt);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; x.a;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;length&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; val_fmt &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$10.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;val_fmt = put(group_test,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$test_group.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;This data step works well and the format is applied to the variable.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 15:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299869#M270338</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2016-09-21T15:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299871#M270339</link>
      <description>&lt;P&gt;700 Options mprint symbolgen;&lt;/P&gt;&lt;P&gt;701 %macro tname(table=,var1=group_test);&lt;/P&gt;&lt;P&gt;702 %do;&lt;/P&gt;&lt;P&gt;703 data temp;&lt;/P&gt;&lt;P&gt;704 set &amp;amp;table;&lt;/P&gt;&lt;P&gt;705 length val_fmt $10.;&lt;/P&gt;&lt;P&gt;706 val_fmt = put(&amp;amp;group_test,$test_group.);/*group_test is the common variable to all datasets&lt;/P&gt;&lt;P&gt;706! that I want to assign the format */&lt;/P&gt;&lt;P&gt;707 run;&lt;/P&gt;&lt;P&gt;708 %end;&lt;/P&gt;&lt;P&gt;709 %mend tname;&lt;/P&gt;&lt;P&gt;710&lt;/P&gt;&lt;P&gt;711 %tname(table=a,var1=group_test);&lt;/P&gt;&lt;P&gt;MPRINT(TNAME): data temp;&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable TABLE resolves to a&lt;/P&gt;&lt;P&gt;MPRINT(TNAME): set a;&lt;/P&gt;&lt;P&gt;MPRINT(TNAME): length val_fmt $10.;&lt;/P&gt;&lt;P&gt;NOTE 137-205: Line generated by the invoked macro "TNAME".&lt;/P&gt;&lt;P&gt;1 data temp; set &amp;amp;table; length val_fmt $10.; val_fmt = put(&amp;amp;group_test,$test_group.);&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;1 ! run;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,&lt;/P&gt;&lt;P&gt;a numeric constant, a datetime constant, a missing value, INPUT, PUT.&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference GROUP_TEST not resolved.&lt;/P&gt;&lt;P&gt;NOTE 137-205: Line generated by the invoked macro "TNAME".&lt;/P&gt;&lt;P&gt;1 data temp; set &amp;amp;table; length val_fmt $10.; val_fmt = put(&amp;amp;group_test,$test_group.);&lt;/P&gt;&lt;P&gt;------------&lt;/P&gt;&lt;P&gt;48&lt;/P&gt;&lt;P&gt;1 ! run;&lt;/P&gt;&lt;P&gt;ERROR 48-59: The format TEST_GROUP was not found or could not be loaded.&lt;/P&gt;&lt;P&gt;MPRINT(TNAME): val_fmt = put(&amp;amp;group_test, $test_group.);&lt;/P&gt;&lt;P&gt;WARNING: Character format specified for the result of a numeric expression.&lt;/P&gt;&lt;P&gt;MPRINT(TNAME): run;&lt;/P&gt;&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by:&lt;/P&gt;&lt;P&gt;(Line):(Column).&lt;/P&gt;&lt;P&gt;1:65&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;P&gt;WARNING: The data set WORK.TEMP may be incomplete. When this step was stopped there were 0&lt;/P&gt;&lt;P&gt;observations and 3 variables.&lt;/P&gt;&lt;P&gt;WARNING: Data set WORK.TEMP was not replaced because this step was stopped.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.00 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 15:33:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299871#M270339</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2016-09-21T15:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299872#M270340</link>
      <description>&lt;P&gt;If this is the program you are putting into a macro, there is one change to make to the macro.&amp;nbsp; Your macro refers to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;group_test&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, it should refer to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;var1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reasons your getting the message about a format are a little tricky, but this should clear them up.&amp;nbsp; I'm happy to explain further if you would like.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 15:33:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299872#M270340</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-21T15:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299879#M270341</link>
      <description>&lt;P&gt;Oh, Yes. This resolved it. Thanks. If I want to call this macro from another library, I thought the following would work. But it doesnt. Any thoughts? Also, is there other way to apply this to all datasets at once?&amp;nbsp;Something that can loop through all the datasets in a library?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;datasets&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;library&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=x;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;change&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; %&lt;STRONG&gt;&lt;I&gt;tname&lt;/I&gt;&lt;/STRONG&gt;(table=b,var1=group_test); &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 15:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299879#M270341</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2016-09-21T15:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299882#M270342</link>
      <description>&lt;P&gt;Now you are referencing a macro without a definition.&lt;/P&gt;
&lt;P&gt;But if it resembles your previous macro FMT you can't have data step code inside a proc datasets call.&lt;/P&gt;
&lt;P&gt;Also I believe you would be looking for MODIFY as that is the instruction for modifying the characteristics of variables.&lt;/P&gt;
&lt;P&gt;CHANGE renames datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Modify datasetname;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; format varaiblename formatname. ;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 15:58:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299882#M270342</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-21T15:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299888#M270343</link>
      <description>&lt;P&gt;Yes, this macro is the same as the one defined above, fmt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In order to use modify on proc datasets, I need to use the statement- modify dataset_name; inside proc datasets; but I have to repeat the same step 10 times to change all of the 10 datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I want to call a macro inside proc datasets and send the dataset name as parameter. Is it possible to do so? Is there any other way?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 16:12:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299888#M270343</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2016-09-21T16:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299889#M270344</link>
      <description>&lt;P&gt;There are two steps you will need to learn about.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, how do you get the list of all data sets to process?&amp;nbsp; If you really want to process all that exist in a library, you can query dictionary.tables.&amp;nbsp; But if&amp;nbsp; you want to limit the search to those that contain a certain variable, you may have to query dictionary.columns.&amp;nbsp; There are other ways ... that's just one viable approach.&amp;nbsp; You might just want to pass a list of data set names as a parameter to the macro, if the list is short enough.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, once you have a list of data sets to process, how do you get the macro to loop through and apply your DATA step to every data set on the list?&amp;nbsp; Here's a link that may help with that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/publishing/2015/01/30/sas-authors-tip-getting-the-macro-language-to-perform-a-do-loop-over-a-list-of-values/" target="_blank"&gt;http://blogs.sas.com/content/publishing/2015/01/30/sas-authors-tip-getting-the-macro-language-to-perform-a-do-loop-over-a-list-of-values/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Each of these steps is probably a little more involved than what you have done so far, but you do have a good first step.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 16:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/299889#M270344</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-21T16:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300191#M270345</link>
      <description>&lt;P&gt;The following did the trick for me:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro tname(tname);

%let var_fmt=group_test;

%do; 

data temp_test;

 set x.&amp;amp;tname; 

 length name $ 30;

 name="&amp;amp;tname";

 length val_fmt $10.;

 val_fmt = put(&amp;amp;var_fmt,$test_group.);

 length member1 3.;

member1= input(var1,3.); /* This conversion doesnt work */

run;

proc append base=one_test data=temp_test force;

run;

%end;

 

%mend tname;

data _null_;

set sashelp.vmember( where=(libname='X' and memtype='DATA'));

call execute('%tname('||strip(memname)||')');

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here the data step&amp;nbsp;in the end&amp;nbsp;pulls all the datasets from my library and calls the macro. This worked like a charm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I am stuck on a very small thing. I am&amp;nbsp;unable to figure out why my conversion from&amp;nbsp;character to numeric &amp;nbsp;doesnt work. Sometimes I get an error- "The length of numeric variables is 3-8" or the values in the new column, member1 show junk values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to run the same conversion on a character variable, whose length is 16 to a numeric, with same length ( Using input statement,)&amp;nbsp;, I get exponential values in the resultant column. Could you solve this please?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 19:06:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300191#M270345</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2016-09-22T19:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300197#M270346</link>
      <description>&lt;P&gt;member1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;var1&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;SPAN class="token comment"&gt;/* This conversion doesnt work */&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token comment"&gt;May not &amp;nbsp;work if var1 exceeds about 65,000 as an integer or contains decimal&amp;nbsp;because you didn't look up what length with Numerics means. Length limits the range of values that may be stored in the specified number of bytes. For most practical purposes the value of limiting the length of numerics has disappeared as the "cost" of data storage has dropped.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token comment"&gt;Another reason you would get bad values is fi var1 exceeds 3 characters. Only the first 3 characters get read into the result. See the result of this code:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data junk;
   var1 = '12345';
   x = input(var1,3.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;x = 123;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token comment"&gt;If you are attempting a generic conversion then you would be better off to 1) not specify the length of a numeric and 2) use a more generic informat such as BEST.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token comment"&gt;Instead of :&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token comment"&gt;&lt;SPAN class="token function"&gt;length&lt;/SPAN&gt; member1 &lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;member1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;var1&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token comment"&gt;try &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token comment"&gt;member1 = input(var1, best16.);&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 19:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300197#M270346</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-22T19:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300207#M270347</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the following error,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Data file X.a.DATA is in a format that is native to another host,&lt;/P&gt;&lt;P&gt;or the file encoding does not match the session encoding. Cross Environment Data Access&lt;/P&gt;&lt;P&gt;will be used, which might require additional CPU resources and might reduce performance."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even though I am not manipulating the source table, but the temp table which I am creating in the data step,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data step however, continues to execute and creates the numeric variable, with length 8.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.s: For the error above, I followed the instructions on &lt;A href="http://support.sas.com/kb/52/716.html" target="_self"&gt;this link&lt;/A&gt;&amp;nbsp; to check the encoding and they are same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 20:12:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300207#M270347</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2016-09-22T20:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300208#M270348</link>
      <description>&lt;P&gt;It would be much easier if you came up with a few examples of the output (MEMBER1) and the input (VAR1) that are causing trouble.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error message you got would only occur if you tried to set the length of a numeric to 2.&amp;nbsp; It shouldn't occur with the code that you posted.&amp;nbsp; SAS does not store numerics as digits.&amp;nbsp; SAS uses a totally different format.&amp;nbsp; So lengths of numerics should only be set to less than 8 when you know the range of values, and when the variable takes on only integer values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the case of your program and data, luckily a length of 3 should be long enough to hold all three-digit integers.&amp;nbsp; If you are getting strange values for MEMBER1, you probably have similarly strange values for VAR1.&amp;nbsp; For example, if VAR1 contained 5E678, the INPUT function would read "5E6" and intpret this as scientific notation.&amp;nbsp; The value would be too large to fit into MEMBER1.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 20:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300208#M270348</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-22T20:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300210#M270349</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code above works for the data step on a sample data I have( length=3). However, my actual data has var1 with a value something like "9812802730090070" Type: text Length=16 . My member1 results in 1.3645456E14 , Type: Numeric, Length=8. Var1 does not contain any strange characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 20:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300210#M270349</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2016-09-22T20:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300213#M270350</link>
      <description>&lt;P&gt;Again, all these efforts to convert character to numeric is because I cannot use a character variable as an analysis in proc tabulate/ proc report. var1 is my ID and I would like to get the count of Id's for my classification variable. Is there a way I could use character variable in proc tabulate/report for analysis? I would not worry about the conversion then.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 20:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300213#M270350</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2016-09-22T20:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300216#M270351</link>
      <description>&lt;P&gt;If you assign the variable a length of 3, but end up with a length of 8, that tells me the length is already set.&amp;nbsp; PROC APPEND adds the variable (with a length of 3), but has to expand that to a length of 8 because the base data set that already exists has a length of 8 for the same variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The extreme changes in the values aren't explainable based on what you have shown so far.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't speak for PROC REPORT, but PROC TABULATE allows you to use both character and numeric variables in the CLASS statement.&amp;nbsp; The VAR statement is limited to numerics only.&amp;nbsp; You would have to check this, but I believe it is possible to get the N statistic (a count) without specifying any VAR variables at all.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 20:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300216#M270351</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-22T20:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300220#M270352</link>
      <description>This helps. Thanks a lot !</description>
      <pubDate>Thu, 22 Sep 2016 20:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300220#M270352</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2016-09-22T20:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300223#M270353</link>
      <description>&lt;P&gt;Appearance for extremely large or small varaibles will end up as exponential notation if you do not specify another format. Please see this code for a very brief example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data junk;
   x=123456789123458;
run;

proc print;
run;

proc print;
   format x best16.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Proc tabulate will handle character looking numerics just fine as a CLASS variable. Just make sure that if you specifically request a statistic for them that you only request the N types: N, PCTN, ROWPCTN, COLPCTN and PAGEPCTN.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 20:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300223#M270353</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-22T20:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use user defined format inside a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300228#M270354</link>
      <description>&lt;P&gt;But in the example I mentioned above, the large value, var1 appears as exponential inspite of specifying the format best16.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro tname(tname);
 %let var_fmt=group_test;
 %do; 
 data temp_test;
 set x.&amp;amp;tname; 
 length name $ 30;
 name="&amp;amp;tname";
 length val_fmt $10.;
 val_fmt = put(&amp;amp;var_fmt,$test_group.);
 member1= input(var1,best16.); /* member1 appears in exponential inspite of specifying the format here */
 run;
 proc append base=one_test data=temp_test force;
 run;
 %end;
 
%mend tname;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, Proc tabulate I just realized it works fine without using the var statement and just adding it in the class statement. I dont have any statistic that requires numeric value. Just needed the count, hence worked well.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 21:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-user-defined-format-inside-a-SAS-macro/m-p/300228#M270354</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2016-09-22T21:17:12Z</dc:date>
    </item>
  </channel>
</rss>

