<?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: SAS macro programme in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883291#M348993</link>
    <description>&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;but can you help me to do it without sql?&lt;/P&gt;&lt;P&gt;I wrote a code, it above this messages, but there are errors.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jul 2023 08:28:02 GMT</pubDate>
    <dc:creator>SASbeginner4</dc:creator>
    <dc:date>2023-07-03T08:28:02Z</dc:date>
    <item>
      <title>SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/882743#M348761</link>
      <description>&lt;P&gt;Hello to everyone, please would you help me in the following.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a macro program to calculate N, Mean, Std, Median, Min and Max for SALARY and for NHITS(SASHELP.BASEBALL)&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Create output dataset using the view which is shown below (Note that “1987 Salary” and “Hits in 1986” are not variable names).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;STATISTIC&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1987 Salary&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Hits in 1986&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;N&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;XX&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;XX&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Mean (Std)&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;XX.X (XX.XX)&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;XX.X (XX.XX)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Median&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;XX.X&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;XX.X&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Min, Max&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;XX, XX&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;XX, XX&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Keep decimal places as shown below.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;N&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;No decimal places&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Mean&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1 decimal place&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Std&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2 decimal places&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Median&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1 decimal place&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Min&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;The same as it is&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;The same as it is&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;Thank you for your help.&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Wed, 28 Jun 2023 07:01:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/882743#M348761</guid>
      <dc:creator>SASbeginner4</dc:creator>
      <dc:date>2023-06-28T07:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/882749#M348764</link>
      <description>&lt;P&gt;Before you start to design the macro, you first need to have the non-macro code which gets the result.&lt;/P&gt;
&lt;P&gt;Since this is advanced homework, you need to go back to the lessons about the basic SAS statistical procedures and start there.&lt;/P&gt;
&lt;P&gt;Once you have your "solve one particular instance" code, post it here, and we can give you hints for the development of your macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keep in mind that homework is meant to test&amp;nbsp;&lt;EM&gt;your&lt;/EM&gt; skills, not&amp;nbsp;&lt;EM&gt;ours&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 07:59:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/882749#M348764</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-06-28T07:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/882751#M348765</link>
      <description>&lt;P&gt;This is what I do, but there are errors&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA file;&lt;BR /&gt;   set SASHELP.BASEBALL;&lt;BR /&gt;RUN;&lt;BR /&gt;proc sort data=file; by Salary nHits; run; &lt;BR /&gt;%MACRO procmean (dataset=, var1=,var2);&lt;BR /&gt;proc means data=&amp;amp;dataset;&lt;BR /&gt;var &amp;amp;var1 &amp;amp;var2;&lt;BR /&gt;output out=file&lt;BR /&gt;n =   N_&amp;amp;var1 N_&amp;amp;var2&lt;BR /&gt;mean= M_&amp;amp;var1 M_&amp;amp;var2&lt;BR /&gt;median= Med_&amp;amp;var1 Med_&amp;amp;var2&lt;BR /&gt;min=min&amp;amp;var1 min&amp;amp;var2&lt;BR /&gt;max=max&amp;amp;var1 max&amp;amp;var2&lt;BR /&gt;run;&lt;BR /&gt;%MEND procmean;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%procmean(dataset=file, var1=Salary, var2=nHits);&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jun 2023 08:34:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/882751#M348765</guid>
      <dc:creator>SASbeginner4</dc:creator>
      <dc:date>2023-06-28T08:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/882757#M348770</link>
      <description>&lt;P&gt;Given the desired output that you show, you would be wise to look at the &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030" target="_self"&gt;%TABLEN macro&lt;/A&gt; and use that, rather than write your own.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 09:27:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/882757#M348770</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-28T09:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/882763#M348774</link>
      <description>&lt;P&gt;Start without any macro elements:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=sashelp.baseball;
var salary nhits;
output ......;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For the correct syntax of the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p04vbvpcjg2vrjn1v8wyf0daypfi.htm" target="_blank" rel="noopener"&gt;OUTPUT Statement&lt;/A&gt;, read the linked documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given your initial assignment, you will need to prepare an intermediate dataset containing salary of one year and nhits of the other; solve this first. Your previous work in the class will have provided you with the necessary skills.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 10:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/882763#M348774</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-06-28T10:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/882780#M348784</link>
      <description>&lt;P&gt;I suggest you check the assignment.&amp;nbsp; Are they really asking you create an output DATASET or perhaps a REPORT?&amp;nbsp; It's not possible to have a dataset with a variable named&amp;nbsp;&lt;SPAN&gt;1987 Salary, because a SAS variable name cannot start with a number.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 11:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/882780#M348784</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-06-28T11:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883018#M348904</link>
      <description>&lt;P&gt;They are the labels, not variable names&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 21:49:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883018#M348904</guid>
      <dc:creator>SASbeginner4</dc:creator>
      <dc:date>2023-06-29T21:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883019#M348905</link>
      <description>&lt;P&gt;You cannot have a single variable that is displayed using different formats at different times.&amp;nbsp; You cannot have a numeric variable that display two different numbers at the same time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to make a CHARACTER variable to hold the values in the cells of your report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use functions to convert the value into strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cell_value = put(n,2.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Will make a string that looks like XX in your first row.&amp;nbsp; If the numbers can be larger then 99 then you will obviously need to use a width or more than 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other examples:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cell_value = put(n,5.);
cell_value = put(mean,6.1)||' ('||put(std,6.2)||')';
cell_value= put(median,6.1);
cell_value = put(min,6.2)||', '||put(max,6.2.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 22:03:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883019#M348905</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-29T22:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883023#M348906</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/445602"&gt;@SASbeginner4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;This is what I do, but there are errors&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA file;&lt;BR /&gt;   set SASHELP.BASEBALL;&lt;BR /&gt;RUN;&lt;BR /&gt;proc sort data=file; by Salary nHits; run; &lt;BR /&gt;%MACRO procmean (dataset=, var1=,var2);&lt;BR /&gt;proc means data=&amp;amp;dataset;&lt;BR /&gt;var &amp;amp;var1 &amp;amp;var2;&lt;BR /&gt;output out=file&lt;BR /&gt;n =   N_&amp;amp;var1 N_&amp;amp;var2&lt;BR /&gt;mean= M_&amp;amp;var1 M_&amp;amp;var2&lt;BR /&gt;median= Med_&amp;amp;var1 Med_&amp;amp;var2&lt;BR /&gt;min=min&amp;amp;var1 min&amp;amp;var2&lt;BR /&gt;max=max&amp;amp;var1 max&amp;amp;var2&lt;BR /&gt;run;&lt;BR /&gt;%MEND procmean;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%procmean(dataset=file, var1=Salary, var2=nHits);&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As mentioned before, &lt;STRONG&gt;get it working without macro code first.&lt;/STRONG&gt; Then you can figure out how to get it working with macro code by replacing parts of the code. Debugging both code and macro at the same time increases the difficulty of the problem significantly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are some references for you: Creating complex reports:&lt;/P&gt;
&lt;P&gt;Paper:&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/173-2008.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/173-2008.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Sample code:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/rnd/papers/sgf2008/complex_reports.zip" target="_blank"&gt;https://support.sas.com/rnd/papers/sgf2008/complex_reports.zip&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And a really old one I wrote that's more than you need here because it looks at categorical and binary variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/2f27939fd72d1dd7d8c8669cd39d7e67" target="_blank"&gt;https://gist.github.com/statgeek/2f27939fd72d1dd7d8c8669cd39d7e67&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you search you'll find many examples online.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 22:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883023#M348906</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-29T22:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883078#M348939</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
Here is an example.
Good Luck.
*/
data have ;
 set SASHELP.BASEBALL;
 keep nHits Salary;
run;
proc sql;
create  view want as
select 'N' as statistic length=20,
       (select put(count(Salary),best. -l) from have) as salary length=40 label='1987 Salary',
    (select put(count(nHits),best. -l) from have) as nHits length=40 label='Hits in 1986'
 from have(obs=1)
union all
select 'Mean(Std)' as statistic length=20,
       cats((select put(mean(Salary),12.1 -l) from have),'(',(select put(std(Salary),12.2 -l) from have),')' ),
       cats((select put(mean(nHits),12.1 -l) from have),'(',(select put(std(nHits),12.2 -l) from have),')' )
 from have(obs=1)
union all
select 'Median' as statistic length=20,
       (select put(median(Salary),12.1 -l) from have) ,
       (select put(median(nHits),12.1 -l) from have) 
 from have(obs=1)
union all
select 'Min,Max' as statistic length=20,
       cats((select put(min(Salary),best. -l) from have),',',(select put(max(Salary),best. -l) from have) ),
       cats((select put(min(nHits),best. -l) from have),',',(select put(max(nHits),best. -l) from have) )
 from have(obs=1)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1688125074925.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85484i9802F6BCA8C00BE4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1688125074925.png" alt="Ksharp_0-1688125074925.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2023 11:37:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883078#M348939</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-06-30T11:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883090#M348946</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/445602"&gt;@SASbeginner4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;They are the labels, not variable name&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;I would still check in with the instructor about the intent of the assignment.&amp;nbsp; It's unusual to want a &lt;EM&gt;dataset&lt;/EM&gt; with information buried in character values like this.&amp;nbsp; It's more typical to want that format as a &lt;EM&gt;report&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2023 13:09:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883090#M348946</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-06-30T13:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883093#M348947</link>
      <description>I think you will need to read on the two types of macro parameters, i.e Keyword and positional parameters. I have a book that can help you in this. &lt;BR /&gt;In this line %MACRO procmean (dataset=, var1=,var2);  you have keyword parameters preceding positional parameters, this is wrong, it should be vicevasa.</description>
      <pubDate>Fri, 30 Jun 2023 13:37:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883093#M348947</guid>
      <dc:creator>himself</dc:creator>
      <dc:date>2023-06-30T13:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883291#M348993</link>
      <description>&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;but can you help me to do it without sql?&lt;/P&gt;&lt;P&gt;I wrote a code, it above this messages, but there are errors.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2023 08:28:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883291#M348993</guid>
      <dc:creator>SASbeginner4</dc:creator>
      <dc:date>2023-07-03T08:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883319#M349002</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA file;
   set SASHELP.BASEBALL;
RUN;
proc sort data=file; by Salary nHits; run; 
%MACRO procmean (dataset=, var1=,var2=);
proc univariate data=&amp;amp;dataset. outtable=temp noprint;
var &amp;amp;var1. &amp;amp;var2.;
run;
data temp2(index=(x=(id Statistic)));
 set temp;
 length Statistic value $ 40;
 id=1;Statistic='N';        value=put(_NOBS_,best. -l);output;
 id=2;Statistic='Mean(Std)';value=cats(put(_MEAN_,12.1 -l),'(',put(_STD_,12.2 -l),')');output;
 id=3;Statistic='Median';   value=put(_MEDIAN_,12.1 -l);output;
 id=4;Statistic='Min,Max';  value=cats(put(_MIN_,best. -l),',',put(_MAX_,best. -l));output;
 keep id _VAR_ _LABEL_ Statistic value;
run;
proc transpose data=temp2 out=want(drop=id _name_);
by id Statistic;
var value;
id _VAR_;
idlabel _LABEL_;
run;
%MEND procmean;


%procmean(dataset=file, var1=Salary, var2=nHits);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Jul 2023 11:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883319#M349002</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-07-03T11:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro programme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883384#M349023</link>
      <description>&lt;P&gt;Thank you very much!!!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2023 06:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-programme/m-p/883384#M349023</guid>
      <dc:creator>SASbeginner4</dc:creator>
      <dc:date>2023-07-04T06:03:16Z</dc:date>
    </item>
  </channel>
</rss>

