<?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 macro to do proc means and proc contents in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253452#M48232</link>
    <description>&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;First,my work is, after I generated these four tables, I need to compare the frequency of all those variables. For example, if I have 2o variables, I need to compare the frequency of each variable, and then list them according to the frequency. I prefer to have a small one so that I can compre by looking at the list of variables directly. I do not know how to use sas to do that step. if you can give me advice, that will be helpful. This is why I ask for four tables seperatedly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second, I am not familiar with the following code&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;indsname&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;source&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
dsetname&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;source&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I searched online. I feel that I should list variable names there. I have many variables. Then how should I list. What is the difference between indsname and dsetname here? I cannot figure out what 'source' means here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Mar 2016 14:39:57 GMT</pubDate>
    <dc:creator>Bal23</dc:creator>
    <dc:date>2016-03-01T14:39:57Z</dc:date>
    <item>
      <title>how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253274#M48157</link>
      <description>&lt;P&gt;I have four datasets, child, adult, senior and over100, each one has over 10000 obs.&lt;/P&gt;&lt;P&gt;the orginal code is very simple&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=bpchild;&lt;BR /&gt;by id;&lt;BR /&gt;run;&lt;BR /&gt;PROC means DATA= bpchild;&lt;BR /&gt;var wvr_:;&lt;BR /&gt;run;&lt;BR /&gt;proc contents data= bpchild;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I just need to replace child with adult, senior, over100.&lt;/P&gt;&lt;P&gt;would anybody teach me how to use macro do this? Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Feb 2016 20:31:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253274#M48157</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-02-29T20:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253276#M48159</link>
      <description>Hi, this should get you started:&lt;BR /&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings13/120-2013.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings13/120-2013.pdf&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Mon, 29 Feb 2016 20:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253276#M48159</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2016-02-29T20:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253278#M48160</link>
      <description>&lt;P&gt;Don't.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Append the files together, use the INDSNAME to identify each source data set and then run a proc means with a BY statement.&lt;/P&gt;
&lt;P&gt;This is more efficient. Datasets of 100K aren't big to SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data all;
set child adult senior over100 indsname=source;
dsetname=source;
run;

proc sort data=all;
by dsetname id;
run;

proc means data=all;
by dsetname;
var wvr:;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Feb 2016 20:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253278#M48160</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-29T20:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253279#M48161</link>
      <description>Wrap your code within a macro definition. The macro needs a parameter, the data sat name. &lt;BR /&gt;The parameter acts as macro variable within the macro, so just replace the data set names in your code with that.&lt;BR /&gt;Then call the macro once for each data set you wish to use.&lt;BR /&gt;See syntax and examples in the on line documentation.</description>
      <pubDate>Mon, 29 Feb 2016 20:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253279#M48161</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-02-29T20:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253291#M48172</link>
      <description>&lt;P&gt;Thanks. But my work is to generate four tables, not a whole picture. Actually, I do&amp;nbsp; have the original dataset, which includes them all. But I am requried to generate four tables.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Feb 2016 21:06:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253291#M48172</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-02-29T21:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253292#M48173</link>
      <description>&lt;P&gt;&amp;nbsp;Thank you. Would you please provide sample code? That will be very helpful. It is hard for me to understand.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Feb 2016 21:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253292#M48173</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-02-29T21:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253301#M48178</link>
      <description>&lt;OL&gt;
&lt;LI&gt;&lt;EM&gt;&lt;CODE class=" language-sas"&gt;Wrap your code in %macro/%mend and assign a name, eg:&lt;/CODE&gt;&lt;/EM&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro summarize;

*your sas code;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Test that it works by calling it.&amp;nbsp;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%summarize;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Change macro to use a parameter &amp;nbsp;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro summarize(dataset);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Change variable name in code to be parameter value, eg:
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=&amp;amp;dataset;
...
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Test again&amp;nbsp;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%summarize(bpchild);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Make sure it works for multiple cases.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 29 Feb 2016 21:30:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253301#M48178</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-29T21:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253378#M48207</link>
      <description>&lt;P&gt;Please clarify on this sentance:&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;But I am requried to generate four tables."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Why are you required to generate four tables. &amp;nbsp;The reason I ask is that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;has provided code which is both simple to read, and efficient in terms of execution. &amp;nbsp;So the question is, why does it then need to be four tables when further procedures can also use by group processing on the data, for instance to report out four tables:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ods tagsets.excelxp file="abc.xlsx" options=(sheet_interval=...);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc report data=...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; by dsetname;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ods tagsets.close;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The thing is, your taking data which can be operated on as one step, splitting it up, then lopping over it each time to do the same thing, and you will find once you split the data every step thereafter than needs to loop over these, which makes life more complicated.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 10:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253378#M48207</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-01T10:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253443#M48231</link>
      <description>&lt;P&gt;Thanks. I am reading it. It takes while for me to finish.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 14:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253443#M48231</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-03-01T14:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253452#M48232</link>
      <description>&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;First,my work is, after I generated these four tables, I need to compare the frequency of all those variables. For example, if I have 2o variables, I need to compare the frequency of each variable, and then list them according to the frequency. I prefer to have a small one so that I can compre by looking at the list of variables directly. I do not know how to use sas to do that step. if you can give me advice, that will be helpful. This is why I ask for four tables seperatedly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second, I am not familiar with the following code&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;indsname&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;source&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
dsetname&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;source&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I searched online. I feel that I should list variable names there. I have many variables. Then how should I list. What is the difference between indsname and dsetname here? I cannot figure out what 'source' means here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 14:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253452#M48232</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-03-01T14:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253455#M48233</link>
      <description>&lt;P&gt;Could you provide test data in the form of a datastep, so that we can provide some code, just guessing from the text here. &amp;nbsp;Help on the indsname option:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.amadeus.co.uk/sas-training/tips/1/1/106/the-indsname-option.php" target="_blank"&gt;http://www.amadeus.co.uk/sas-training/tips/1/1/106/the-indsname-option.php&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically you would create a variable which holds the name of the dataset that data comes from, in the example given by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;, this would be child or adult etc.&lt;/P&gt;
&lt;P&gt;This variable is then used as a bygroup, you can also do frequencies and other things using by group.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 14:45:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253455#M48233</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-01T14:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253457#M48234</link>
      <description>&lt;P&gt;I have searched online and found the link you provided. Unfortunately, with my current computer, I could not access, maybe because of setting problems.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 14:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253457#M48234</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-03-01T14:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253466#M48238</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Create sample data;
data childhave;
input patientid var_hed var_eye var_col var_leg var_hea var_lea var_alh;
cards;
371130 1 . . . . . 1

214144 . 1 . . . . . 

181841 . . . . 1.1

168065 . . 1....
779199 . . . 1 1 .
155981 1 . 1 . . . .
603224 . . . . . 1 .

;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;this is my test data, for one dataset, child group&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 15:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253466#M48238</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-03-01T15:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253467#M48239</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40773"&gt;@Bal23﻿&lt;/a&gt;&amp;nbsp;Have you tried the steps I've outlined. Besides writing the code letter for letter for you, I'm not sure how else to explain it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're having trouble, post the code you've tried.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You've also stated you want 4 tables, the BY does generate 4 separate tables.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 15:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253467#M48239</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-01T15:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253469#M48241</link>
      <description>&lt;P&gt;As I said, I do not understand how to use this&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;indsname&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;source&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
dsetname&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;source&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I did search online, I got the same link that I could not access&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I provided my sample data a few minutes ago. Please check and it will be great if you can provide help regarding my sample data, since I do not know how to modify your above code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 15:54:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253469#M48241</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-03-01T15:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253471#M48243</link>
      <description>&lt;P&gt;indsname is a dataset option. It identifies records by creating a variable that stores the name of the data set that provides the record.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, that variable isn't stored automatically, so you need to reassign it in your data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is only valid in SAS 9.3+&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;STRONG&gt;INDSNAME=variable&lt;/STRONG&gt;
creates and names a variable that stores the name of the SAS data set from which the current observation is read. The stored name can be a data set name or a physical name. The physical name is the name by which the operating environment recognizes the file.
Tips	For data set names, SAS adds the library name to the variable value (for example, WORK.PRICE) and converts the two-level name to uppercase.
Unless previously defined, the length of the variable is set to 41 bytes. Use a LENGTH statement to make the variable length long enough to contain the value of the physical filename if the filename is longer than 41 bytes.
If the variable is previously defined as a character variable with a specific length, that length is not changed. If the value placed into the INDSNAME variable is longer than that length, then the value is truncated.
If the variable is previously defined as a numeric variable, an error will occur.
The variable is available in the DATA step, but the variable is not added to any output data set.
Example	Retrieving the Name of the Data Set from Which the Current Observation Is Read&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p00hxg3x8lwivcn1f0e9axziw57y.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p00hxg3x8lwivcn1f0e9axziw57y.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 15:57:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253471#M48243</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-01T15:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253482#M48245</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Create sample data;
data childhave;
input patientid var_hed var_eye var_col var_leg var_hea var_lea var_alh;
cards;
371130 1 . . . . . 1

214144 . 1 . . . . . 

181841 . . . . 1.1

168065 . . 1....
779199 . . . 1 1 .
155981 1 . 1 . . . .
603224 . . . . . 1 .

;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&amp;nbsp; I have read this. Without any example, it is hard for me to do. (i did click but was not able to get any example).&lt;/P&gt;&lt;P&gt;Therefore, I copied and pasted my sample data set again&amp;nbsp; and hope to get sample code from you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 16:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253482#M48245</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-03-01T16:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253506#M48258</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/38890"&gt;@cynthia﻿&lt;/a&gt;I have read the note from the link you provided however, I still do not know how to apply it to solve my problem.&lt;/P&gt;&lt;P&gt;As Reeza said below (that is originally a kind of my plan, but not in details, as he provided). however, I still have trouble to do it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="lia-message-body lia-component-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;OL&gt;&lt;LI&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macrobound"&gt;%macro&lt;/SPAN&gt; summarize&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="token comment"&gt;*your sas code;&lt;/SPAN&gt;

&lt;SPAN class="token macrobound"&gt;%mend&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;&lt;CODE class="  language-sas"&gt;%macro sum; proc sort data=bp2&amp;amp;sum; by patientid; run; PROC means DATA=bp2&amp;amp;sum; var wvr_:; run; %mend; data want; set bp2&amp;amp;sum; run; %sum(child, adult, senior, over100) &lt;/CODE&gt;&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;Test that it works by calling it.&amp;nbsp;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%summarize&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;LI&gt;Change macro to use a parameter &amp;nbsp;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macrobound"&gt;%macro&lt;/SPAN&gt; summarize&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;dataset&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;LI&gt;Change variable name in code to be parameter value, eg:&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;means&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;dataset&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 punctuation"&gt;.&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;LI&gt;Test again&amp;nbsp;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%summarize&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;bpchild&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;LI&gt;Make sure it works for multiple cases.&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 01 Mar 2016 17:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253506#M48258</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-03-01T17:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253507#M48259</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is my code, based on your code above&lt;/P&gt;&lt;P&gt;I am thinking to have a variable that can be used to replace child, adult, senior and over100. There are some problems with this code, so please give advice. thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro sum;

  proc sort data=bp2&amp;amp;sum;
by patientid;
run;
 PROC means DATA=bp2&amp;amp;sum;
var wvr_:;
run;

    %mend;
	
data want;
set bp2&amp;amp;sum;
run;
%sum(child, adult, senior, over100)

  

    &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Mar 2016 17:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253507#M48259</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-03-01T17:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to use macro to do proc means and proc contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253515#M48263</link>
      <description>&lt;P&gt;So from the test data you posted:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; childhave&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; patientid var_hed var_eye var_col var_leg var_hea var_lea var_alh&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You proc means is simply:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc means data=childhave;
  var var_:;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 17:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-macro-to-do-proc-means-and-proc-contents/m-p/253515#M48263</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-01T17:35:34Z</dc:date>
    </item>
  </channel>
</rss>

