Descibe a data set

Contents

proc contents data=sashelp.gnp;
run;
<!DOCTYPE html> SAS Output

The SAS System

Data Set Name SASHELP.GNP Observations 126
Member Type DATA Variables 6
Engine V9 Indexes 0
Created 10/25/2018 02:16:03 Observation Length 48
Last Modified 10/25/2018 02:16:03 Deleted Observations 0
Protection   Compressed NO
Data Set Type   Sorted NO
Label gnp/macro data (quarterly: 1960-1991)    
Data Representation SOLARIS_X86_64, LINUX_X86_64, ALPHA_TRU64, LINUX_IA64    
Encoding us-ascii ASCII (ANSI)    
Engine/Host Dependent Information
Data Set Page Size 65536
Number of Data Set Pages 1
First Data Page 1
Max Obs per Page 1360
Obs in First Data Page 126
Number of Data Set Repairs 0
Filename /opt/sasinside/SASHome/SASFoundation/9.4/sashelp/gnp.sas7bdat
Release Created 9.0401M6
Host Created Linux
Inode Number 2511
Access Permission rw-r–r–
Owner Name sas
File Size 128KB
File Size (bytes) 131072
Alphabetic List of Variables and Attributes
# Variable Type Len Format Label
3 CONSUMP Num 8   personal consumption expenditures
1 DATE Num 8 YYQ.  
5 EXPORTS Num 8   net exports of goods and services
2 GNP Num 8   gross national product ($billions)
6 GOVT Num 8   govt purchases of goods and services
4 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

The SAS System

Obs DATE GNP CONSUMP INVEST EXPORTS GOVT
1 1960Q1 516.1 325.5 88.7 4.3 97.6
2 1960Q2 514.5 331.6 78.1 5.1 99.6
3 1960Q3 517.7 331.7 77.4 6.5 102.1
4 1960Q4 513.0 333.8 68.5 7.7 103.0
5 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

The SAS System

Q-Q plot for GNP

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

The SAS System

Q-Q plot for DATE


The SAS System

svgtitle Q-Q plot for GNP -3 -2 -1 0 1 2 3 Normal Quantiles -4000 -2000 0 2000 4000 6000 8000 gross national product ($billions) Mu=2239.6, Sigma=1593.5 Normal Line Q-Q Plot for GNP

The SAS System

svgtitle Q-Q plot for CONSUMP -3 -2 -1 0 1 2 3 Normal Quantiles -2000 0 2000 4000 6000 personal consumption expenditures Mu=1448.8, Sigma=1068.5 Normal Line Q-Q Plot for CONSUMP

The SAS System

svgtitle Q-Q plot for INVEST -3 -2 -1 0 1 2 3 Normal Quantiles -500 0 500 1000 1500 gross private domestic investment Mu=348.22, Sigma=236.85 Normal Line Q-Q Plot for INVEST

The SAS System

svgtitle Q-Q plot for EXPORTS -3 -2 -1 0 1 2 3 Normal Quantiles -150 -100 -50 0 50 100 150 net exports of goods and services Mu=-6.594, Sigma=38.752 Normal Line Q-Q Plot for EXPORTS

The SAS System