SAS Macro : Determine the number of rows and variables in a dataset

Suppose you need to find out the number of rows and number of character and numeric variables in a data set.
data _null_;
if 0 then set correl nobs=n;
array nums _numeric_;
array chars _character_;
nvar = dim(nums);
cvar = dim(chars);
tvar= nvar + cvar;
call symput ('nrows',n);
call symput('numer',nvar);
call symput('chars',cvar);
call symput('totvar',tvar);

%put &nrows;
%put &numer;
%put &chars;
%put &totvar;

In this program, correl is a data set.
Related Posts
Spread the Word!
About Author:
Deepanshu Bhalla

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

0 Response to "SAS Macro : Determine the number of rows and variables in a dataset"

Post a Comment

Next → ← Prev
Looks like you are using an ad blocker!

To continue reading you need to turnoff adblocker and refresh the page. We rely on advertising to help fund our site. Please whitelist us if you enjoy our content.