Descibe a data set

Contents

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

The CONTENTS Procedure

Data Set Name SASHELP.HEART Observations 5209
Member Type DATA Variables 17
Engine V9 Indexes 0
Created 10/25/2018 02:21:26 Observation Length 168
Last Modified 10/25/2018 02:21:26 Deleted Observations 0
Protection   Compressed NO
Data Set Type   Sorted NO
Label Framingham Heart Study    
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 14
First Data Page 1
Max Obs per Page 389
Obs in First Data Page 365
Number of Data Set Repairs 0
Filename /opt/sasinside/SASHome/SASFoundation/9.4/sashelp/heart.sas7bdat
Release Created 9.0401M6
Host Created Linux
Inode Number 6235
Access Permission rw-r–r–
Owner Name sas
File Size 960KB
File Size (bytes) 983040
Alphabetic List of Variables and Attributes
# Variable Type Len Label
12 AgeAtDeath Num 8 Age at Death
5 AgeAtStart Num 8 Age at Start
3 AgeCHDdiag Num 8 Age CHD Diagnosed
15 BP_Status Char 7 Blood Pressure Status
14 Chol_Status Char 10 Cholesterol Status
13 Cholesterol Num 8  
2 DeathCause Char 26 Cause of Death
8 Diastolic Num 8  
6 Height Num 8  
10 MRW Num 8 Metropolitan Relative Weight
4 Sex Char 6  
11 Smoking Num 8  
17 Smoking_Status Char 17 Smoking Status
1 Status Char 5  
9 Systolic Num 8  
7 Weight Num 8  
16 Weight_Status Char 11 Weight Status

First few rows of the data set

proc print data=sashelp.heart (obs=5);
run;
<!DOCTYPE html> SAS Output
Obs Status DeathCause AgeCHDdiag Sex AgeAtStart Height Weight Diastolic Systolic MRW Smoking AgeAtDeath Cholesterol Chol_Status BP_Status Weight_Status Smoking_Status
1 Dead Other . Female 29 62.50 140 78 124 121 0 55 .   Normal Overweight Non-smoker
2 Dead Cancer . Female 41 59.75 194 92 144 183 0 57 181 Desirable High Overweight Non-smoker
3 Alive   . Female 57 62.25 132 90 170 114 10 . 250 High High Overweight Moderate (6-15)
4 Alive   . Female 39 65.75 158 80 128 123 0 . 242 High Normal Overweight Non-smoker
5 Alive   . Male 42 66.00 156 76 110 116 20 . 281 High Optimal Overweight Heavy (16-25)

Horizontal box plot for a continuous variable

ods graphics on/noborder;
  
    proc sgplot data=sashelp.heart;
       
        hbox weight;
            
        title "Boxplot for variable %sysfunc(upcase(weight)) from data set %sysfunc(upcase(sashelp.heart))";
    
    run;
    
    title;
    
ods graphics off;
<!DOCTYPE html> SAS Output

The SGPlot Procedure

Options

options mcompilenote=ALL symbolgen mprint;

<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>

114  ods listing close;ods html5 (id=saspy_internal) file=stdout options(bitmap_mode='inline') device=svg style=HTMLBlue; ods
114! graphics on / outputfmt=png;
NOTE: Writing HTML5(SASPY_INTERNAL) Body file: STDOUT
115
116 options mcompilenote=ALL symbolgen mprint;
117
118 ods html5 (id=saspy_internal) close;ods listing;

119

Data driven horizontal box plots

Compile the macro

%macro hbox(lib=sashelp, df=heart);


%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 graphics on/noborder;
  
    proc sgplot data=&dfn;
       
        hbox &&col&i;
            
        title "Boxplot for %upcase(&&col&i) from data set %upcase(&lib..&dfn)";
    
    run;
    
    title;
    
ods graphics off;

%end;
   
   
%mend ;

<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>

182  ods listing close;ods html5 (id=saspy_internal) file=stdout options(bitmap_mode='inline') device=svg style=HTMLBlue; ods
182! graphics on / outputfmt=png;
NOTE: Writing HTML5(SASPY_INTERNAL) Body file: STDOUT
183
184 %macro hbox(lib=sashelp, df=heart);
185
186
187 %let dfn=%scan(&lib..&df, -1);
188
189 data &dfn;
190
191 set &lib..&df;
192
193 keep _numeric_;
194 run;
195
196
197 %let dfn=%upcase(&dfn);
198
199
200 data _null_;
201
202 set sashelp.vcolumn end=final;
203
204 where libname="WORK" and memname="&dfn";
205
206 call symputx('col'||left(_n_), name);
207
208 if final then call symputx('totalcol', _n_);
209
210 run;
211
212 %do i=1 %to &totalcol;
213
214 ods graphics on/noborder;
215
216 proc sgplot data=&dfn;
217
218 hbox &&col&i;
219
220 title "Boxplot for %upcase(&&col&i) from data set %upcase(&lib..&dfn)";
221
222 run;
223
224 title;
225
226 ods graphics off;
227
228 %end;
229
230
231 %mend ;
NOTE: The macro HBOX completed compilation without errors.
33 instructions 1216 bytes.
232
233 ods html5 (id=saspy_internal) close;ods listing;

234

Call the default macro

%hbox()
<!DOCTYPE html> SAS Output

The SGPlot Procedure


svgtitle The SGPlot Procedure 30 40 50 60 Age at Start Boxplot for AGEATSTART from data set SASHELP.HEART

svgtitle The SGPlot Procedure 50 55 60 65 70 75 Height Boxplot for HEIGHT from data set SASHELP.HEART

svgtitle The SGPlot Procedure 100 150 200 250 300 Weight Boxplot for WEIGHT from data set SASHELP.HEART

svgtitle The SGPlot Procedure 50 75 100 125 150 Diastolic Boxplot for DIASTOLIC from data set SASHELP.HEART

svgtitle The SGPlot Procedure 100 150 200 250 300 Systolic Boxplot for SYSTOLIC from data set SASHELP.HEART

svgtitle The SGPlot Procedure 100 150 200 250 Metropolitan Relative Weight Boxplot for MRW from data set SASHELP.HEART

svgtitle The SGPlot Procedure 0 10 20 30 40 50 60 Smoking Boxplot for SMOKING from data set SASHELP.HEART

svgtitle The SGPlot Procedure 40 60 80 Age at Death Boxplot for AGEATDEATH from data set SASHELP.HEART

svgtitle The SGPlot Procedure 100 200 300 400 500 Cholesterol Boxplot for CHOLESTEROL from data set SASHELP.HEART