As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Difference between revisions of "Macro Array Package"

From sasCommunity
Jump to: navigation, search
m
m (added name to .sig datetime-stamp)
Line 112: Line 112:
 
</pre>
 
</pre>
  
--macro maven == the radical programmer 16:26, 15 January 2008 (EST) 3/30/2007 11:44AM
+
--macro maven == the radical programmer 3/30/2007 11:44AM
  
 
[[Category:SAS Code]]
 
[[Category:SAS Code]]
 
[[Category:Macro Language]]
 
[[Category:Macro Language]]

Revision as of 16:27, 15 January 2008

The Macro Array Package

(C)  2007 Ronald J. Fehd

SAS-L's macro maven

todo: add link to the .pdf and zip file containing the 100 programs in the .pdf

http://www.sascommunity.org/wiki/Image:TheMacroArrayPackage.pdf

http://www.sascommunity.org/wiki/Image:TheMacroArrayPackage.zip

Contents

1 Introduction                             4

2 Concepts                                 4

2.1 Development Task Checklists . . . . .  4

2.1.1 List Processing . . . . . . . . . .  4

2.1.2 Writing Calling Macros  . . . . . .  5

2.2 Making Unique Lists . . . . . . . . .  5

2.3 Replacing The Dim Function  . . . . .  7

2.3.1 Data Step: Array and Dim Function .  7

2.3.2 Number of Items . . . . . . . . . .  9

2.3.3 Number of Observations  . . . . . . 10

2.4 Making Arrays of Macro Variables  . . 11

2.4.1 Horizontal List: Scan . . . . . . . 11

2.4.2 Vertical List: Call Symputx . . . . 12

2.4.3 Vertical List: SQL select into  . . 12



3 Demonstration of Usage                  14

3.1 Note: autoexec.sas  . . . . . . . . . 14

3.2 Using Data Sets . . . . . . . . . . . 14

3.3 Using Lists . . . . . . . . . . . . . 15

3.4 Using Dictionary Tables: Memnames . . 15

3.5 Note on Using SAShelp Views . . . . . 16



4 Examples                                17

4.1 Calling Macros  . . . . . . . . . . . 18

4.1.1 Calling Macros with Data + Var  . . 18

4.1.2 Calling Macros with Lists . . . . . 19

4.1.3 Calling Macros with Either  . . . . 23

4.2 Reports . . . . . . . . . . . . . . . 24

4.2.1 Report Freq . . . . . . . . . . . . 25

4.2.2 Report Means  . . . . . . . . . . . 26

4.2.3 Report sashelp.Shoes Sales  . . . . 26



5 Example Applications                    27

5.1 Testing . . . . . . . . . . . . . . . 27

5.1.1 Subroutine: PutParms  . . . . . . . 27

5.1.2 Options Mprint  . . . . . . . . . . 28

5.2 Generic Reports . . . . . . . . . . . 28

5.2.1 Report sashelp.Class: Freq  . . . . 28

5.2.2 Report sashelp.Class: Means . . . . 29

5.2.3 Report sashelp.Shoes: Means . . . . 29

5.3 Specific Report: sashelp.Shoes  . . . 30

5.3.1 Report Shoe Sales with Data + Var . 30

5.3.2 Report Shoe Sales with List . . . . 30

6 The Macros                              32

6.1 array.sas . . . . . . . . . . . . . . 32

6.1.1 arrayTestData.sas . . . . . . . . . 36

6.1.2 arrayTestList.sas . . . . . . . . . 37

6.2 vartype.sas . . . . . . . . . . . . . 37

6.2.1 vartypeTest.sas . . . . . . . . . . 39

6.2.2 vartypeTest.log . . . . . . . . . . 39

--macro maven == the radical programmer 3/30/2007 11:44AM