<?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 to use defined format in the macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-defined-format-in-the-macro/m-p/910176#M358969</link>
    <description>&lt;P&gt;It worked！ Thank u&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jan 2024 22:52:06 GMT</pubDate>
    <dc:creator>Sikcion</dc:creator>
    <dc:date>2024-01-02T22:52:06Z</dc:date>
    <item>
      <title>How to use defined format in the macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-defined-format-in-the-macro/m-p/910172#M358965</link>
      <description>&lt;P&gt;Hi guys! I have one question about&amp;nbsp; how to use defined format in the macro?&lt;/P&gt;&lt;P&gt;Firstly, I've defined the format before the macro:&lt;/P&gt;&lt;PRE&gt;proc format;
value $sex
 "F"="Female"
 "M"="Male";
 
value $ethnic
 "HISPANIC OR LATINO"="Hispanic or Latino"
 "NOT HISPANIC OR LATINO"="Not Hispanic or Latino";
 
value $race
"AMERICAN INDIAN OR ALASKA NATIVE"="American Indian or Alaska Native"
"ASIAN"="Asian"
"BLACK OR AFRICAN AMERICAN"="Black or African American"
"NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER"="Native Hawaiian or other Pacific Islander"
"WHITE"="White"
"MULTIPLE"="Multiple";

value $remiss
"SECOND COMPLETE REMISSION" ="2nd"
"THIRD COMPLETE REMISSION"="3rd";

value race
 1="American Indian or Alaska Native"
 2="Asian"
 3="BLACK OR AFRICAN AMERICAN"="Black or African American"
 4="Native Hawaiian or other Pacific Islander"
 5="White"
 6="Multiple";
 run;&lt;/PRE&gt;&lt;P&gt;then I want to use the format in the macro statement:&lt;/P&gt;&lt;PRE&gt;/**Age/Sex/Ethnic/Remiss Categorical statistics**/;
%macro cate_stat(varc= ,label=);
proc freq data=ADSL noprint;
  tables Trt01an *&amp;amp;varc / missing outpct out=&amp;amp;varc;
run;


proc freq data=ADSL noprint;
tables trt01an/missing out=&amp;amp;varc._n(drop=percent);
run;

data &amp;amp;varc._total;
set  &amp;amp;varc._n &amp;amp;varc;
by trt01an;
keep &amp;amp;varc trt01an count pct_row;
run;

data &amp;amp;varc._total(drop=pct_row count);
set &amp;amp;varc._total;
by trt01an;
length value $11.  ;
if &amp;amp;varc ne " " then 
value=put(count,3.)|| "(" || put(pct_row,4.1)||"%)";
else if &amp;amp;varc eq " " then do;
value=put(count,3.);
&amp;amp;varc=0;
end;
run;

proc sort data=&amp;amp;varc._total;
by  &amp;amp;varc;
run;

proc transpose data=&amp;amp;varc._total
  out=&amp;amp;varc._final (drop=_name_)
  prefix=Trt;
  by &amp;amp;varc;
  var value;
  id Trt01an;
run;

data &amp;amp;varc._final( rename=(&amp;amp;varc="&amp;amp;label"n));
set &amp;amp;varc._final;
if &amp;amp;varc = 0 then &amp;amp;varc="n";
format &amp;amp;varc $&amp;amp;varc.;
run;

%mend;
%cate_stat(varc=AGegr1,label=Age group(yr));
%cate_stat(varc=sex,label=Sex));
%cate_stat(varc=ETHNIC,label=Ethnicity);
%cate_stat(varc=remiss,label=Current remission Status Score);&lt;/PRE&gt;&lt;P&gt;while it has error and i don't know how to fix it! Thanks for your help!&lt;/P&gt;&lt;PRE&gt;       
 NOTE: Line generated by the macro variable "VARC".
 272         $remiss
              ______
              22
              76
 
 ERROR 22-322: Expecting a format name.  
 
 ERROR 76-322: Syntax error, statement will be ignored.&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jan 2024 22:36:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-defined-format-in-the-macro/m-p/910172#M358965</guid>
      <dc:creator>Sikcion</dc:creator>
      <dc:date>2024-01-02T22:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to use defined format in the macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-defined-format-in-the-macro/m-p/910173#M358966</link>
      <description>&lt;P&gt;Since it involves a macro, you ought to turn on macro debugging tools by running this line of code and then re-running the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As stated in your other thread, we need to see the ENTIRE log for the part of the code that has the problem. In this case, you need to show us the ENTIRE log for the DATA step or PROC where the error happens, that's every single line for this PROC or DATA step, including lines of code in the log and all NOTEs, WARNINGsand ERRORs. Please do this EVERY time you have an error in your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 22:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-defined-format-in-the-macro/m-p/910173#M358966</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-02T22:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to use defined format in the macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-defined-format-in-the-macro/m-p/910175#M358968</link>
      <description>Your FORMAT statement at the end of the macro needs to add another dot:&lt;BR /&gt;&lt;BR /&gt;format &amp;amp;amp;varc $&amp;amp;amp;varc..;&lt;BR /&gt;&lt;BR /&gt;Reason:  when referring to a macro variable, you have the choice of adding a dot.  Both &amp;amp;varc and &amp;amp;varc. refer to the macro variable named "varc".</description>
      <pubDate>Tue, 02 Jan 2024 22:53:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-defined-format-in-the-macro/m-p/910175#M358968</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2024-01-02T22:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to use defined format in the macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-defined-format-in-the-macro/m-p/910176#M358969</link>
      <description>&lt;P&gt;It worked！ Thank u&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 22:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-defined-format-in-the-macro/m-p/910176#M358969</guid>
      <dc:creator>Sikcion</dc:creator>
      <dc:date>2024-01-02T22:52:06Z</dc:date>
    </item>
  </channel>
</rss>

