Data is included in the script via the DATALINES statement.
1 Code Block
DATA STEP Data
Explanation : Creation of the 'Color' table from internal data. The '@@' operator allows reading multiple observations on the same data line.
Copied!
title 'Hair Color of European Children';
data Color;
input Region Eyes $ Hair $ Count @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
label Eyes ='Eye Color'
Hair ='Hair Color'
Region='Geographic Region';
datalines;
1 blue fair 23 1 blue red 7 1 blue medium 24
1 blue dark 11 1 green fair 19 1 green red 7
1 green medium 18 1 green dark 14 1 brown fair 34
1 brown red 5 1 brown medium 41 1 brown dark 40
1 brown black 3 2 blue fair 46 2 blue red 21
2 blue medium 44 2 blue dark 40 2 blue black 6
2 green fair 50 2 green red 31 2 green medium 37
2 green dark 23 2 brown fair 56 2 brown red 42
2 brown medium 53 2 brown dark 54 2 brown black 13
;
1
title 'Hair Color of European Children';
2
3
DATA Color;
4
INPUT Region Eyes $ Hair $ Count @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
5
label Eyes ='Eye Color'
6
Hair ='Hair Color'
7
Region='Geographic Region';
8
DATALINES;
9
1 blue fair 231 blue red 71 blue medium 24
10
1 blue dark 111 green fair 191 green red 7
11
1 green medium 181 green dark 141 brown fair 34
12
1 brown red 51 brown medium 411 brown dark 40
13
1 brown black 32 blue fair 462 blue red 21
14
2 blue medium 442 blue dark 402 blue black 6
15
2 green fair 502 green red 312 green medium 37
16
2 green dark 232 brown fair 562 brown red 42
17
2 brown medium 532 brown dark 542 brown black 13
18
;
2 Code Block
PROC SORT
Explanation : Sorting data by the 'Region' variable. The 'ods select none' statement disables sending output to active ODS destinations (like the Results window) to avoid displaying unnecessary reports for sorting.
Copied!
ods select none;
proc sort data=Color;
by Region;
run;
1
ods select none;
2
3
PROC SORTDATA=Color;
4
BY Region;
5
RUN;
3 Code Block
PROC FREQ Data
Explanation : Calculation of frequencies and statistical tests. 'ods output ChiSq=myStats' captures the ODS 'ChiSq' table generated by PROC FREQ and stores it in the SAS table 'myStats'. Dataset options filter to keep only statistics starting with 'Chi' or 'Like'.
Explanation : Reactivation of ODS display ('ods select all') and display of the content of the 'myStats' output table containing the captured statistical results.
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.