SAS : Difference between SYMPUT and SYMGET

Live Online Training : SAS Programming with Practical Examples

- Explain Programming Concepts in Simple English
- Live Projects
- Scenario Based Questions
- Mock Interview
- 100+ Base and Advanced SAS Certification Questions
- Get 10% off till Jan 22, 2018
- Batch starts from February 10, 2018

This tutorial explains the difference between SYMPUT and SYMPUT in SAS.

SYMPUT : To create macro variables in a data step.
SYMGET : To get macro variable value in a data step.

Example 1 : Creating a single macro variable
*Creating a macro variable;
data _null_;
set sashelp.class;
if _N_ = 1 then do;
call symput('nvar', name);
%put &nvar;
*Get macro variable value in a dataset;
data want;
 Example 2 : Creating multiple macro variables
*Creating macro variables;
data _null_;
set sashelp.class;
call symput('nvars' || strip(_n_), name);
%put &nvars1 &nvars2 &nvars3;
* Number of rows;
data _null_;
if 0 then set sashelp.class nobs=n;
call symput ('nrows',n);
*Get macro variable value in a dataset;
data want (drop = i);
do i=1 to &nrows.;

SAS Tutorials : 100 Free SAS Tutorials

About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 7 years of experience in data science and predictive modeling. During his tenure, he has worked with global clients in various domains like banking, Telecom, HR and Health Insurance.

While I love having friends who agree, I only learn from those who don't.

Let's Get Connected: Email | LinkedIn

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*
Related Posts:
3 Responses to "SAS : Difference between SYMPUT and SYMGET"
  1. Really insightful , thanks . my first time with macros

  2. Your interview questions are really helpful for revision as well. Thank you so much for helping out everyone. Your great experience and expertise is really creating wonders.


Next → ← Prev