Presentation is loading. Please wait.

Presentation is loading. Please wait.

©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc.

Similar presentations


Presentation on theme: "©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc."— Presentation transcript:

1 ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration SYMply PUT: GET the most out of SYMPUTX and SYMGETN SYMply PUT: GET the most out of SYMPUTX and SYMGETN Robert Howard Veridical Solutions San Diego, CA

2 SYMply PUT: GET the most out of SYMPUTX and SYMGETN Call SYMPUTX routine SYMGETN and SYMGET functions PUT it all together: A Practical Example Presentation Outline ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration

3 SYMply PUT: GET the most out of SYMPUTX and SYMGETN The CALL SYMPUTX Routine Used in the DATA step Stores values into macro variables Once stored, these values can be accessed globally throughout a program ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration

4 SYMply PUT: GET the most out of SYMPUTX and SYMGETN The CALL SYMPUTX Routine Syntax: call symputx(macro-variable,value); The macro-variable argument can be: a) A character string in quotation marks b) A character variable name The value argument can be: a) A character or numeric value b) A character or numeric variable name ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration

5 SYMply PUT: GET the most out of SYMPUTX and SYMGETN The CALL SYMPUTX Routine Example 1: data _null_; call symputx(thisyear,2011); call symputx(trt0,Placebo); run; %put &thisyear &trt0; The log result displays: 2011 Placebo ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration

6 SYMply PUT: GET the most out of SYMPUTX and SYMGETN The CALL SYMPUTX Routine Example 2: data _null_; set dset1; call symputx(name,age); run; %put &chaz &mac &ellie &savannah &jillian &alex &ayden &quinn; The log result displays: ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration DSET1

7 SYMply PUT: GET the most out of SYMPUTX and SYMGETN SYMGET and SYMGETN functions Also used in the DATA step Retrieves values of previously stored macro variables and assigns these values in programmer-defined variables SYMGET is used to retrieve character values SYMGETN is used to retrieve numeric values ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration

8 SYMply PUT: GET the most out of SYMPUTX and SYMGETN SYMGET and SYMGETN functions Syntax for SYMGET: =symget(macro-variable); Syntax for SYMGETN: =symgetn(macro-variable); The macro-variable argument can be: a) The name of a macro-variable with no ampersand (within single quotes) b) The name of a variable with values that have been assigned as macro variables (no quotes) ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration

9 SYMply PUT: GET the most out of SYMPUTX and SYMGETN SYMGET and SYMGETN functions Example 3: Recall previous example where &thisyear has a stored value of Since &thisyear is numeric, we will use SYMGETN data dset2; year=symgetn(thisyear); run; DSET2 ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration

10 SYMply PUT: GET the most out of SYMPUTX and SYMGETN SYMGET and SYMGETN functions Example 4: data dset4; set dset3; age=symgetn(name); run; DSET3 DSET4 DSET4 is created with a new variable, AGE, which contains the corresponding values associated with each instance of NAME. ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration

11 SYMply PUT: GET the most out of SYMPUTX and SYMGETN PUT it all together: A Practical Example DSET5 Calculate the number and percentages of subjects by gender for each treatment group. proc freq data=dset5 noprint; tables treat / out=trtfreq; run; TRTFREQ First obtain number of subjects in each Treatment Group. ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration

12 SYMply PUT: GET the most out of SYMPUTX and SYMGETN PUT it all together: A Practical Example Using the CALL SYMPUTX routine, we assign macro variables for the value of TREAT data _null_; set trtfreq; call symputx(treat,count); run; TRTFREQ The macro variables &A and &B are assigned with values 8 and 3, respectively. ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration

13 SYMply PUT: GET the most out of SYMPUTX and SYMGETN PUT it all together: A Practical Example Now well obtain the number of Male and Female subjects by Treatment Group. proc freq data=dset5 noprint; tables treat*gender / out=freq0; run; FREQ0 ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration

14 SYMply PUT: GET the most out of SYMPUTX and SYMGETN PUT it all together: A Practical Example Well use the SYMGETN function to calculate the percentages FINAL data final; set freq0; percent=put(count/symgetn(treat),percent7.1); run; ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration

15 SYMply PUT: GET the most out of SYMPUTX and SYMGETN simple, yet powerful tools efficient and effective method to store and retrieve macro variables use together to save time and keep program dynamic In Conclusion The CALL SYMPUTX routine and SYMGETN and SYMGET functions are: ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration

16 SYMply PUT: GET the most out of SYMPUTX and SYMGETN Rob Howard Veridical Solutions P.O. Box 656 Del Mar, CA Thank you for your time and interest! ©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration


Download ppt "©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc."

Similar presentations


Ads by Google