datalines drop file infile input keep label length output put retain setAns:
Executable | Declarative |
---|---|
input | datalines |
put | drop |
set | file |
infile | |
keep | |
length | |
retain |
* Version 1; len = length(age_gender); if substr(age_gender, len) = "*" then do; age = substr(age_gender, 1, len - 1); gender = "F"; end; else do; age = age_gender; gender = "M"; end; * Version 2; len = length(age_gender); if index(age_gender, "*") = 0 then do; age = age_gender; gender = "M"; end; else do; age = scan(age_gender, -1); gender = "F"; end;
* To create local copy on a different machine: libname local 'c:/datasets/local'; data local.class; set sashelp.class; * To restore on your machine: libname local 'c:/datasets/local'; data sashelp.class; set local.class;
data temp; set sashelp.class; keep Height Weight symb; if sex = 'M' then symb = 1; else if sex = 'F' then symb = 2; goptions reset=all; symbol1 c = blue h = 2 v = >; symbol2 c = red h = 2 v = *; proc gplot; plot Weight * Height = symb;
ods html style=statistical; proc sgplot data=sashelp.class; scatter x = Weight y = Height / group = sex;To choose your own plotting symbols, create an ODS graphics style template as in the Iris2 Example.
Inoculated | Infected | Count |
---|---|---|
0 | 0 | 473 |
1 | 0 | 276 |
0 | 1 | 66 |
1 | 1 | 3 |
data cholera; input innoculated $ infected $ count; datalines; 0 0 473 1 0 276 0 1 66 1 1 3 ; proc format; value $YESNO "0"="No" "1"="Yes"; proc freq; table innoculated * infected / nopercent norow nocol nocum; weight count; format innoculated $YESNO. infected $YESNO.; proc gchart; * Side-by-side bars for innoculated. vbar infected / group=innoculated freq=count; proc gchart; * Stacked bars for innoculated. vbar infected / subgroup=innoculated freq=count; proc sgplot; * Side-by-side bars for innoculated. vbar infected / group=innoculated groupdisplay=cluster freq=count barwidth=0.8; proc sgplot; * Stacked bars for innoculated. vbar infected / group=innoculated freq=count;
Style | Output | Comments |
---|---|---|
HTMLBLUE | Full Color | White background, optimized for HTML output |
DEFAULT | Full Color | Gray background, optimized for HTML output |
ANALYSIS | Full Color | Yellow background |
STATISTICAL | Full Color | White background, colored fills |
LISTING | Full Color | White background, optimized for
color format on white paper |
JOURNAL | Gray Scale | Interior filled areas are gray scale |
ods html style=statistical;
proc template; list styles;
proc template; source styles.statistical;
proc means data=sashelp.class n mean; var age; by sex; where age < 13; label sex='Gender';