Descibe a data set
Contents
proc contents data=sashelp.gnp;
run;
<!DOCTYPE html>
SAS Output
|
SASHELP.GNP
|
126
|
|
DATA
|
6
|
|
V9
|
0
|
|
10/25/2018 02:16:03
|
48
|
|
10/25/2018 02:16:03
|
0
|
|
|
NO
|
|
|
NO
|
|
gnp/macro data (quarterly: 1960-1991)
|
|
|
SOLARIS_X86_64, LINUX_X86_64, ALPHA_TRU64, LINUX_IA64
|
|
|
us-ascii ASCII (ANSI)
|
|
|
65536
|
|
1
|
|
1
|
|
1360
|
|
126
|
|
0
|
|
/opt/sasinside/SASHome/SASFoundation/9.4/sashelp/gnp.sas7bdat
|
|
9.0401M6
|
|
Linux
|
|
2511
|
|
rw-r–r–
|
|
sas
|
|
128KB
|
|
131072
|
|
CONSUMP
|
Num
|
8
|
|
personal consumption expenditures
|
|
DATE
|
Num
|
8
|
YYQ.
|
|
|
EXPORTS
|
Num
|
8
|
|
net exports of goods and services
|
|
GNP
|
Num
|
8
|
|
gross national product ($billions)
|
|
GOVT
|
Num
|
8
|
|
govt purchases of goods and services
|
|
INVEST
|
Num
|
8
|
|
gross private domestic investment
|
First few rows of the data set
proc print data=sashelp.gnp (obs=5);
run;
<!DOCTYPE html>
SAS Output
|
1960Q1
|
516.1
|
325.5
|
88.7
|
4.3
|
97.6
|
|
1960Q2
|
514.5
|
331.6
|
78.1
|
5.1
|
99.6
|
|
1960Q3
|
517.7
|
331.7
|
77.4
|
6.5
|
102.1
|
|
1960Q4
|
513.0
|
333.8
|
68.5
|
7.7
|
103.0
|
|
1961Q1
|
517.4
|
334.4
|
69.5
|
8.3
|
105.3
|
Q-Q plot for a continuous variable (i.e., gnp)
proc univariate data=sashelp.gnp;
ods select qqplot;
var gnp;
qqplot gnp / normal(mu=est sigma=est);
run;
<!DOCTYPE html>
SAS Output
Options
options mcompilenote=ALL symbolgen mprint;
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
62 ods listing close;ods html5 (id=saspy_internal) file=stdout options(bitmap_mode='inline') device=svg style=HTMLBlue; ods
62 ! graphics on / outputfmt=png;
NOTE: Writing HTML5(SASPY_INTERNAL) Body file: STDOUT
63
64 options mcompilenote=ALL symbolgen mprint;
65
66 ods html5 (id=saspy_internal) close;ods listing;
67
Compile a macro for creating data driven Q-Q plots
%macro qqplot(lib=sashelp, df=gnp);
%let dfn=%scan(&lib..&df, -1);
data &dfn;
set &lib..&df;
keep _numeric_;
run;
%let dfn=%upcase(&dfn);
data _null_;
set sashelp.vcolumn end=final;
where libname="WORK" and memname="&dfn";
call symputx('col'||left(_n_), name);
if final then call symputx('totalcol', _n_);
run;
%do i=1 %to &totalcol;
ods noproctitle;
ods graphics on/noborder;
proc univariate data=&dfn;
ods select qqplot;
var &&col&i;
qqplot &&col&i / normal(mu=est sigma=est);
run;
ods graphics off;
%end;
%mend ;
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
196 ods listing close;ods html5 (id=saspy_internal) file=stdout options(bitmap_mode='inline') device=svg style=HTMLBlue; ods
196! graphics on / outputfmt=png;
NOTE: Writing HTML5(SASPY_INTERNAL) Body file: STDOUT
197
198 %macro qqplot(lib=sashelp, df=gnp);
199
200
201 %let dfn=%scan(&lib..&df, -1);
202
203 data &dfn;
204
205 set &lib..&df;
206
207 keep _numeric_;
208 run;
209
210
211 %let dfn=%upcase(&dfn);
212
213
214 data _null_;
215
216 set sashelp.vcolumn end=final;
217
218 where libname="WORK" and memname="&dfn";
219
220 call symputx('col'||left(_n_), name);
221
222 if final then call symputx('totalcol', _n_);
223
224 run;
225
226 %do i=1 %to &totalcol;
227
228 ods noproctitle;
229
230 ods graphics on/noborder;
231
232 proc univariate data=&dfn;
233 ods select qqplot;
234 var &&col&i;
235 qqplot &&col&i / normal(mu=est sigma=est);
236 run;
237
238 ods graphics off;
239
240 %end;
241
242
243 %mend ;
NOTE: The macro QQPLOT completed compilation without errors.
35 instructions 1264 bytes.
244
245 ods html5 (id=saspy_internal) close;ods listing;
246
Call the default macro
In this data set all variables are truly continuous in nature.
%qqplot()
<!DOCTYPE html>
SAS Output