Appendix B: Skip Pattern Data Codebook
This appendix contains the SAS program used to create a codebook for the “Skip Pattern” data set used in the Chapter 7 examples. This is the cleaned version of the data after all skip patterns in the raw data have been audited and corrected. This raw skip pattern data was simulated for the examples. Any similarity to actual data is merely a coincidence.
SAS Program to Create Codebook
Program B-1 shows the SAS statements to create the codebook shown in Codebook B-1.
Section 1: In-line formatting is used in the TITLE and FOOTNOTE statements to customize the justification, font, and font size used in the codebook.
Section 2: Macro variables are used to store the location of folders for the Data Detective’s Toolkit SAS programs, the data set that will be used to create the codebook, and the folder where the output will be saved.
Section 3: PROC FORMAT is used to create the formats assigned to variables in the data set. Note that the special SAS missing values of .L and .N are included in the VALUE statements for many of the formats.
Section 4: The %TK_codebook macro is invoked to create the codebook. The parameters are used to identify:
● The libref where the data set is stored (lib=work)
● The name of the SAS data set (file1=skippatterndata_cln)
● The libref where the format library is stored (fmtlib=work)
● The ODS destination for the type of codebook you want to create (cb_type=RTF)
● The name of the file that you want to store the codebook (cb_file = &cb_name).
◦ &cb_name is the macro variable that was created in Section 2 to hold the name of the codebook that you want to create.
● The order you want the variables listed in the codebook (var_order=internal)
◦ The internal keyword tells %TK_codebook that you want the variables listed in the same order as they are stored in the SAS data set.
● The size of the codebook (cb_size=FULL) indicates you want all information listed on every variable.
● The organization of the codebook (organization=One record per Participant (CASEID), which will be included with the data set information at the beginning of the codebook.
● The flag for the potential problem reports (include_warn=NO), which is turned off. These reports were examined when the data set was created, with all problems investigated and solved.
Program B-1: Create Codebook for the Skip Pattern Data Set Created in Chapter 7
* Section 1) Add options to embellish titles and footnotes;
title j=center height=10pt font=Arial Bold Italic “Cleaned Skip Pattern Data Codebook from Chapter 7”;
footnote j=left height=9pt font=Arial “Data created for illustrating the Data Detective’s Toolkit.”;
* Section 2) Define folders, name of codebook, and include codebook
program;
%let TKFolder = /Data_Detective/Book/SAS_programs/TK_toolkit;
%let DataFolder = /Data_Detective/Book/SAS_Datasets;
%let WorkFolder = /Data_Detective/Book/SAS_Output;
libname SAS_data “&DataFolder”;
%let cb_name=&WorkFolder/CodebookB_1.rtf;
%include “&TKFolder/TK_codebook.sas”;
* Section 3) Create formats;
proc format;
value VERSION 1=’Pilot’ 2=’Production’;
value DEM1f 18 - 99 = “Valid Range”;
value DEM2f 1=’Female’ 2=’Male’;
value DEM3f 1 = ‘White’
2 = ‘Black or African American’
3 = ‘Hispanic’
4 = ‘Asian’
5 = ‘Other’
6 = ‘Refused’;
value DEM4f 1 = “< High School”
2 = ‘High School Graduate/GED’
3 = “Some College/vocational school (no degree)”
4 = “2-year college/vocational/Associate’s degree”
5 = “4-year college or higher (BA, BS, MA, MS, PhD)”
;
value TOB1f 1 = “Yes” 2 = “No (Go to Section 3)”;
value TOB2f 0-30= “Valid Range” .L = “Legitimate Skip”
.E=”Expected Reply, Not Answered”;
value TOB3f 1 = “Yes” 2 = “No “ .L = “Legitimate Skip”
.E=”Expected Reply, Not Answered”;
value TOB4f 1 = “Yes” 2 = “No “ .L = “Legitimate Skip”
.E=”Expected Reply, Not Answered”;
value TOB5f 1 = “Smoke the same amount”
2 = “Increase the amount of cigarettes smoked”
3 = “Decrease the amount of cigarettes smoked”
4 = “Quit smoking cigarettes altogether”
.L = “Legitimate Skip”
.E=”Expected Reply, Not Answered”;
value PG1f 1 = “Yes” 2 = “No (Go to End of Survey)”
.L = “Legitimate Skip” .E=”Expected Reply, Not Answered”;
value PG2f 1 - 10 =”Valid Range” .L = “Legitimate Skip”
.E=”Expected Reply, Not Answered”;
value PG3f 1 - 10 =”Valid Range” .L = “Legitimate Skip”
.N = “Question Not Available” .E=”Expected Reply, Not Answered”;
value PG4f 1 = “Yes” 2 = “No (Go to End of Survey)”
3 = “Unsure (Go to End of Survey)” .L = “Legitimate Skip”
.E=”Expected Reply, Not Answered”;
value PG5f 0 - 9 =”Valid Range” .L = “Legitimate Skip”
.E=”Expected Reply, Not Answered”;
value $anytext ‘ ‘=’Missing (blank)’ other=’Text or value supplied’;
value $showall default = 20 ‘ ‘=’Missing (blank)’;
value shownum . = ‘SAS Missing (.)’ other = _same_;
value anymiss .=’SAS Missing (.)’ other=’Any Number’;
value version 1 = “Date started: June 15, 2020”
2 = “Date started: July 31, 2020”;
value MODE 1 = “WEB” 2 = “MAIL”;
run;
data work.skippatterndata_cln(label=”Cleaned Skip Pattern Data”);
set SAS_data.skippatterndata_cln;
format svy_mode mode.;
format version version.;
run;
* Section 4) Create codebook;
%TK_codebook(lib=work,
file1=skippatterndata_cln,
fmtlib=work,
cb_type=RTF,
cb_file=&cb_name,
var_order=internal,
cb_size=BRIEF,
organization = One record per Participant (CASEID),
include_warn=NO);
run;
The codebook is shown in Codebook B-1.
Codebook B-1: Codebook for the Cleaned Skip Pattern Data Set from Chapter 7
Cleaned Skip Pattern Data Codebook from Chapter 7 Data Set: skippatterndata_cln.sas7bdat Label: Cleaned Skip Pattern Data Date Created: 17NOV20:21:58:16 Number of Observations: 701 Number of Variables: 17 Organization of Data Set: One record per Participant (CASEID) |
||||||
Label |
Type |
Values |
Frequency Category |
Frequency |
Percent |
|
CASEID |
Unique identifier for participant |
Num 8 |
. |
SAS missing (.) |
0 |
0.00 |
10000 to 10700 |
Range |
701 |
100.00 |
|||
SVY_MODE |
MODE of Data Collection (1=WEB, 2=MAIL) |
Num 8 |
1 |
WEB |
348 |
49.64 |
2 |
|
353 |
50.36 |
|||
VERSION |
VERSION of Data Collection Instrument: 1=Pilot, 2=Production |
Num 8 |
1 |
Date started: June 15, 2020 |
149 |
21.26 |
2 |
Date started: July 31, 2020 |
552 |
78.74 |
|||
DEM1 |
How old are you? |
Num 8 |
. |
SAS missing (.) |
61 |
8.70 |
18-99 |
Valid Range |
640 |
91.30 |
|||
DEM2 |
Sex of participant |
Num 8 |
1 |
Female |
331 |
47.22 |
2 |
Male |
370 |
52.78 |
|||
DEM3 |
Race/Ethnicity |
Num 8 |
. |
SAS missing (.) |
24 |
3.42 |
1 |
White |
408 |
58.20 |
|||
2 |
Black or African American |
162 |
23.11 |
|||
3 |
Hispanic |
58 |
8.27 |
|||
4 |
Asian |
20 |
2.85 |
|||
5 |
Other |
17 |
2.43 |
|||
6 |
Refused |
12 |
1.71 |
|||
DEM4 |
Highest grade/year of school completed |
Num 8 |
1 |
< High School |
46 |
6.56 |
2 |
High School Graduate/GED |
137 |
19.54 |
|||
3 |
Some College/vocational school (no degree) |
179 |
25.53 |
|||
4 |
2-year college/vocational/Associate’s degree |
114 |
16.26 |
|||
5 |
4-year college or higher (BA, BS, MA, MS, PhD) |
225 |
32.10 |
|||
TOB1 |
Ever smoked a cigarette, even one or two puffs? |
Num 8 |
1 |
Yes |
342 |
48.79 |
2 |
No (Go to Section 3) |
359 |
51.21 |
|||
TOB2 |
[Ask if TOB1=1] On how many of the past 30 days did you smoke a cigarette? |
Num 8 |
.L |
Legitimate Skip |
359 |
51.21 |
0-30 |
Valid Range |
342 |
48.79 |
|||
TOB3 |
[Ask if TOB1=1] Smoked at least 100 cigarettes in your life? |
Num 8 |
.E |
Expected Reply, Not Answered |
7 |
1.00 |
.L |
Legitimate Skip |
359 |
51.21 |
|||
1 |
Yes |
166 |
23.68 |
|||
2 |
No |
169 |
24.11 |
|||
TOB4 |
[Ask if TOB1=1] Stopped smoking cigarettes for 1 or more days because trying to quit? |
Num 8 |
.L |
Legitimate Skip |
359 |
51.21 |
1 |
Yes |
190 |
27.10 |
|||
2 |
No |
152 |
21.68 |
|||
TOB5 |
[Ask if TOB1=1 and TOB2>0] In the next 3 months do you think your will ... |
Num 8 |
.E |
Expected Reply, Not Answered |
39 |
5.56 |
.L |
Legitimate Skip |
365 |
52.07 |
|||
1 |
Smoke the same amount |
175 |
24.96 |
|||
2 |
Increase the amount of cigarettes smoked |
75 |
10.70 |
|||
3 |
Decrease the amount of cigarettes smoked |
23 |
3.28 |
|||
4 |
Quit smoking cigarettes altogether |
24 |
3.42 |
|||
PG1 |
[Ask if DEM2=1] Ever been pregnant? |
Num 8 |
.L |
Legitimate Skip |
370 |
52.78 |
1 |
Yes |
159 |
22.68 |
|||
2 |
No (Go to End of Survey) |
172 |
24.54 |
|||
PG2 |
[Ask if DEM2=1 AND PG1=1] How many pregnancies have you had? |
Num 8 |
.L |
Legitimate Skip |
542 |
77.32 |
1-10 |
Valid Range |
159 |
22.68 |
|||
PG3 |
[Ask if DEM2=1 AND PG1=1 AND VERSION>1] How many pregnancies did you have that did not result in live birth? |
Num 8 |
.L |
Legitimate Skip |
425 |
60.63 |
.N |
Question Not Available |
149 |
21.26 |
|||
1-10 |
Valid Range |
127 |
18.12 |
|||
PG4 |
[Ask if DEM2=1 AND PG1=1] Are you pregnant now? |
Num 8 |
.L |
Legitimate Skip |
542 |
77.32 |
1 |
Yes |
41 |
5.85 |
|||
2 |
No (Go to End of Survey) |
79 |
11.27 |
|||
3 |
Unsure (Go to End of Survey) |
39 |
5.56 |
|||
PG5 |
[Ask if DEM2=1 AND PG4=1 AND PG1=1] How many months pregnant are you? |
Num 8 |
.L |
Legitimate Skip |
660 |
94.15 |
0-9 |
Valid Range |
41 |
5.85 |
|||
3.144.189.177