Dept. of Biostatistics and Epidemiology at the :

BioEpi 691F: Practical Data Management and Statistical Computing

1995 Final Exam

Solutions


A study of smoking in black populations has been conducted to reduce cigarette smoking. You have used some data from this study in completing Assignment #11. We will use data from Assignment #11, and additional data in the final exam.

As previously summarized, the study design includes a baseline survey identifying smokers in four cities, followed by a 1 year intervention. Additional surveys are conducted on approximately 25% of the smokers identified at baseline after 6 months, 12 months, with a complete assessment on all smokers identified at baseline at 18 months. The 12 month survey was conducted initially by telephone, and subsequently by home interviews (if phone contact could not be made). Data for a subset of subjects in this study are given in the five data files (lec11d4.sd2, lec11d5.sd2, lec11d6.sd2, lec11d7.sd2 and lec11d8.sd2). These data are identical to the data used in Assignment 11.


Some additional data were collected at the 18 month visit. The additional data identified detailed data on quit smoking attempts, and data on factors considered important for quitting smoking.


Your task is to incorporate these data into the data from the baseline, 6, 12, and 18 month surveys. In constructing answers to the questions, you should construct answers that would be suitable to implement with a much larger data set, even though the data you have includes only few subjects. Please write separate SAS programs to answer each question when a SAS program is called for. In particular, do the following:

1. Create a EPI INFO questionnaire, and enter and verify all the new data (see attached). Print a copy of your questionnaire (*.qes) and the entered data (*.rec) to turn in, along with a listing of the data.

2. Create a permanent SAS data set from your EPI INFO data, label the variables and data set, and create formats for variables where needed. Print a copy of the contents of the data set to turn in.

3. Combine previous data sets (lec11d4.sd2, lec11d5.sd2, lec11d6.sd2, lec11d7.sd2 and lec11d8.sd2) into a single data set (or use your result from Assignment #11, part 2). Using each subject's date of birth (DOB) and age started smoking (S_AGE), calculating the number of years smoking (including fractions of a year) up to the 18 month visit date (VDATE). Name this variable YRSMOK. When calculating the variable, assume the subject started smoking on their birthday when they first turned their starting smoking age (S_AGE). Set the variable YRSMOK to missing if a subject quit smoking at the 18 month visit (QUIT=1).

For subjects still smoking at the 18 month visit, average this number with the number of years smoked (T_SMOKE), and take the integer part to estimate the number of years smoking for subjects who haven't quit at 18 months. For subjects who have quit at 18 months, use only the variable T_SMOKE to estimate the years smoking. For other subjects with data missing at 18 month visit, use as the years smoking the calculated years assuming the 18 month visit date is 12/1/94. Name this final variable for the years smoking F_YRSM. Label variables appropriately.

Turn in a list of years smoked in sorted order from lowest to highest years smoked according to F_YRSM. Include in your list the following variables in this order: ID, YRSMOK, T_SMOKE, F_YRSM, and QUIT. Save the data set with these variables as a permanent SAS data set.

4. Group the number of years smoking into two groups, <30, 30+. Summarize the percent of persons feeling the reasons (given in the additional questionnaire) are important to stop smoking, for each group (< 30 and 30+).

5. (Optional- for an A) Assume that the quit data for subjects in the additional questionnaire was collected at the same time as the 18 month questionnaire data. Also, assume that the quit MONTH and YEAR indicates the start of the quitting period, with the person first quitting on the 15th day of the quit month. With these assumptions, calculate the number of days each person was smoke free in the past year (including in the past year the 18 month visit day, and defining a year as a total of 365 days ). Obtain a listing of the subject Ids accompanied by the number of smoke free days in each episode (in the past year), and the total number of smoke free days, where your listing is in increasing order of the total number of smoke free days. Also construct a horizontal chart of the frequency of smoke free weeks. Turn the listing and chart in.

6. Include a copy of your SAS program(s), and your documentation for work on this exam.


Additional Questionnaire at 18 Months

City:

Springfield
Hartford
Durham
Columbia

ID: ______

Did you quit smoking for at least 24 hours in the past 18 months?

  • Yes
  • No

When was the last time you quit and succeeded for more than 24 hours?

How many days were you able to quit that time?

Months

Years

Days

Last Time

XX

XX

XXX

2nd Last Time

XX

XX

XXX

3rd Last Time

XX

XX

XXX

Which of the following reasons do you think are important reasons to stop smoking?

  • 1 Save money
    2 Improve taste/smell
  • 3 Feel better
  • 4 Follow doctor's advice
  • 5 Avoil illness
  • 6 Set example for kids
  • 7 Help health problem
  • 8 Please a loved one
  • 9 Get control over life
  • 10 Meet religious rules

________________________________________________________________

Solutions to Final Exam.
 

1. We create a questionnaire in EPI INFO, allowing separate variables for city and for ID. We set ranges for some variables (allowing years to range from 90-95), and let the "reason" variables be coded as values of 1 (yes) or blank (no), with values of quit smoking coded as 1 (Yes) or 0 (No). A list of the questionnaire is given in lecfea.qes.

2. Listing of Data Contents

 

We include as a format a YES/NO format, using this format also for the "Important reason" for quitting.

 Simple Listing of SAS Data

 

Last Last Last 2nd Last 2nd Last 2nd Last 3nd Last 3rd Last 3rd Last

Quit Quit Quit Quit Quit Quit Quit Quit Quit Quit

City: ID: Smoking? Mth? Yr? Days? Mth? Yr? Days? Mth? Yr? Days?

A1 A2 :A3 :A4a1 :A4a2 :A4a3 :A4b1 :A4b2 :A4b3 :A4c1 :A4c2 :A4c3

 

S 1 Yes 1 95 10 6 94 95 . . .

S 2 Yes 8 94 10 2 94 45 . . .

S 3 etc

 

Part 3. Next, we create a variable from the baseline and 18 month data corresponding to the years smoked for each subject. A listing of the variable created follows.

 

Listing of Years Smoked for Subjects

 

Baseline Final

Calculate Estimated

Subject Yrs Yrs Yrs Quit

ID: Smoked: Smoked: Smoked: smoking?:

ID yrsmok T_SMOKE f_yrsm QUIT

 

C0006 16.1786 15 15 0

H0002 18.1081 15 15 1

H0004 17.9090 . 17 .

C0002 21.3539 20 20 0

S0003 24.4127 20 22 0

H0006 27.8576 23 25 0

C0005 29.1821 25 27 0

C0001 34.4702 30 30 1

H0009 33.6420 30 31 0

S0002 37.2772 32 34 0

S0001 42.2847 30 36 0

D0001 46.0240 40 43 0

D0002 49.0116 45 45 1

D0003 55.6653 50 52 0

 

 

Part 4. We create a program to summarize the proportion of subjects with shorter smoking history (< 30 years) and longer smoking history (GE 30 years) who indicate various reasons are important to quit smoking. A total of 7 subjects fall into each of these smoking categories. The proportions are summarized below.

 

Summary of Proportion of Subjects considering Factors Important to Quit Smoking by Years smoked

 

----------------------------------------------------------

| |Smoked*30+yrs?:*:F_YRSM1 |

| |-------------------------|

| | No | Yes |

| |------------+------------|

| | Prop. | Prop. |

| | Important | Important |

|------------------------------+------------+------------|

|Save*Money*:A5A | 0.29| 0.57|

|------------------------------+------------+------------|

|Improve*taste/smell*:A5B | 0.00| 0.43|

|------------------------------+------------+------------|

|Feel*Better*:A5C | 0.43| 0.57|

|------------------------------+------------+------------|

|Feel*Better*:A5C | 0.43| 0.57|

|------------------------------+------------+------------|

|Avoid*llness*:A5E | 0.29| 0.29|

|------------------------------+------------+------------|

|Set*example*for*kids*:A5F | 0.14| 0.43|

|------------------------------+------------+------------|

|Help*health*probl*:A5G | 0.14| 0.00|

|------------------------------+------------+------------|

|Please*a loved*one*:A5H | 0.14| 0.29|

|------------------------------+------------+------------|

|Get*control*:A5I | 0.29| 0.14|

|------------------------------+------------+------------|

|Meet*religious*rules*:A5J | 0.00| 0.00|

----------------------------------------------------------

 

Part 5. We create the number of smoke free days for each subject. A list and chart follows:

 

List of Smoke Free Days in Past Year

 

Days

Smoke

Free:

CITY SUBJECT DAY1 DAY2 DAY3 sfree

 

C 5 0 0 0 0

D 1 0 0 0 0

D 3 0 0 0 0

H 2 0 0 0 0

H 9 2 0 0 2

S 3 14 0 0 14

C 2 7 30 0 37

H 4 0 30 7 37

C 1 19 7 14 40

S 2 10 45 0 55

C 6 3 14 60 77

H 6 90 0 0 90

S 1 10 95 0 105

D 2 338 0 0 338

 

Frequency Distribution of Smoke Free Weeks in Past Year

Note: -1 indicates no smoke free days

 

Weeks*smoke*free:*csfree Cum. Cum.

Midpoint Freq Freq Percent Percent

|

-2 | 0 0 0.00 0.00

-1 |******************************************************************************** 4 4 28.57 28.57

0 |******************** 1 5 7.14 35.71

1 |******************** 1 6 7.14 42.86

2 | 0 6 0.00 42.86

3 | 0 6 0.00 42.86

4 | 0 6 0.00 42.86

5 |************************************************************ 3 9 21.43 64.29

6 | 0 9 0.00 64.29

7 |******************** 1 10 7.14 71.43

8 | 0 10 0.00 71.43

9 | 0 10 0.00 71.43

10 |******************** 1 11 7.14 78.57

11 | 0 11 0.00 78.57

12 |******************** 1 12 7.14 85.71

13 | 0 12 0.00 85.71

14 |******************** 1 13 7.14 92.86

15 | 0 13 0.00 92.86

16 | 0 13 0.00 92.86

17 | 0 13 0.00 92.86

18 | 0 13 0.00 92.86

19 | 0 13 0.00 92.86

20 | 0 13 0.00 92.86

21 | 0 13 0.00 92.86

22 | 0 13 0.00 92.86

23 | 0 13 0.00 92.86

24 | 0 13 0.00 92.86

25 | 0 13 0.00 92.86

26 | 0 13 0.00 92.86

27 | 0 13 0.00 92.86

28 | 0 13 0.00 92.86

29 | 0 13 0.00 92.86

30 | 0 13 0.00 92.86

31 | 0 13 0.00 92.86

32 | 0 13 0.00 92.86

33 | 0 13 0.00 92.86

34 | 0 13 0.00 92.86

35 | 0 13 0.00 92.86

36 | 0 13 0.00 92.86

37 | 0 13 0.00 92.86

38 | 0 13 0.00 92.86

39 | 0 13 0.00 92.86

40 | 0 13 0.00 92.86

41 | 0 13 0.00 92.86

42 | 0 13 0.00 92.86

43 | 0 13 0.00 92.86

44 | 0 13 0.00 92.86

45 | 0 13 0.00 92.86

46 | 0 13 0.00 92.86

47 | 0 13 0.00 92.86

48 |******************** 1 14 7.14 100.00

49 | 0 14 0.00 100.00

|

--------------------+-------------------+-------------------+-------------------+

Frequency Distribution of Smoke Free Weeks in Past Year

Note: -1 indicates no smoke free days

 

1 2 3 4

 

Frequency

 

 

 

 

 

 

 

 

Documentation on PH691F Disk 5

 

*P****************************************************************************;

*P*lecfep1.SAS 12/13/95 c691f #5 Ed Stanek *;

*P* DESCRIPTION: Final exam 1995 creation of additional*;

*P* data for smoking study from EPI INFO file *;

*P*Z* lecfe1.sd2 Additional data from smoking study *;

*P*Z* entered and verified in EPIINFO *;

*P*Z* created by lecfep1.sas *;

*P*Z* lecfe1f.sd2 Formats for Additional data from smoking study *;

*P*Z* created by lecfep1.sas *;

*P****************************************************************************;

*P*lecfep2.SAS 12/13/95 c691f #5 Ed Stanek *;

*P* DESCRIPTION: Create combined data with years smoking*;

*P* from baseline and 18 month data sets for question *;

*P* two in final 1995 *;

*P*Z* lecfe2.sd2 Combined data from baseline and 18 month *;

*P*Z* with re-computed years smoking *;

*P*Z* created from: lec11d4.sd2 baseline data *;

*P*Z* and lec11d8.sd2 18 mth data *;

*P*Z* created by lecfep2.sas *;

*P****************************************************************************;

*P*lecfep3.SAS 12/13/95 c691f #5 Ed Stanek *;

*P* DESCRIPTION: Combine data on years smoked with *;

*P* additional data, and tabulate results for important*;

*P* reasons *;

*P* lecfe2.sd2 Combined data from baseline and 18 month *;

*P* with re-computed years smoking *;

*P* lecfe1.sd2 Additional data at 18 months *;

*P****************************************************************************;

*P*lecfep4.SAS 12/13/95 c691f #5 Ed Stanek *;

*P* DESCRIPTION: Calculate the number of smoke free *;

*P* days in the past year for subjects using additional*;

*P* data *;

*P* lecfe1.sd2 Additional data at 18 months *;

*****************************************************************************;

 

*P*Z* lecfe1.sd2 Additional data from smoking study *;

*P*Z* entered and verified in EPIINFO *;

*P*Z* created by lecfep1.sas *;

*P*Z* lecfe1f.sd2 Formats for Additional data from smoking study *;

*P*Z* created by lecfep1.sas *;

*P*Z* lecfe2.sd2 Combined data from baseline and 18 month *;

*P*Z* with re-computed years smoking *;

*P*Z* created from: lec11d4.sd2 baseline data *;

*P*Z* and lec11d8.sd2 18 mth data *;

*P*Z* created by lecfep2.sas *;

 

A Listing of the Programs follows:

 

Listing of LECFE1.SAS

 

OPTIONS LS=128 PS=60 NODATE NONUMBER NOCENTER;

*P****************************************************************************;

*P*lecfep1.SAS 12/13/95 c691f #5 Ed Stanek *;

*P* DESCRIPTION: Final exam 1995 creation of additional*;

*P* data for smoking study from EPI INFO file *;

*P*Z* lecfe1.sd2 Additional data from smoking study *;

*P*Z* entered and verified in EPIINFO *;

*P*Z* created by lecfep1.sas *;

*P*Z* lecfe1f.sd2 Formats for Additional data from smoking study *;

*P*Z* created by lecfep1.sas *;

***************************************************************************;

LIBNAME old4 V604 "c:\sph\" ;

LIBNAME new V610 "c:\sph" ;

 

DATA new.LECFE1 (LABEL="Additional Smoking Data: lecfep1.sas");

INPUT

A1 $1

A2 2-3

A3 4

A4A1 5-6

A4A2 7-8

A4A3 9-11

A4B1 12-13

A4B2 14-15

A4B3 16-18

A4C1 19-20

A4C2 21-22

A4C3 23-25

A5A 26

A5B 27

A5C 28

A5D 29

A5E 30

A5F 31

A5G 32

A5H 33

A5I 34

A5J 35 ;

LABEL A1 ="City:*A1"

A2 ="ID:*A2"

A3 ="Quit*Smoking?*:A3"

A4A1 ="Last*Quit*Mth?*:A4a1"

A4A2 ="Last*Quit*Yr?*:A4a2"

A4A3 ="Last*Quit*Days?*:A4a3"

A4B1 ="2nd Last*Quit*Mth?*:A4b1"

A4B2 ="2nd Last*Quit*Yr?*:A4b2"

A4B3 ="2nd Last*Quit*Days?*:A4b3"

A4C1 ="3nd Last*Quit*Mth?*:A4c1"

A4C2 ="3rd Last*Quit*Yr?*:A4c2"

A4C3 ="3rd Last*Quit*Days?*:A4c3"

A5A ="Save*Money*:A5A"

A5B ="Improve*taste/smell*:A5B"

A5C ="Feel*Better*:A5C"

A5D ="Follow*doctors*advice*:A5D"

A5E ="Avoid*llness*:A5E"

A5F ="Set*example*for*kids*:A5F"

A5G ="Help*health*probl*:A5G"

A5H ="Please*a loved*one*:A5H"

A5I ="Get*control*:A5I"

A5J ="Meet*religious*rules*:A5J";

LENGTH DEFAULT=3;

CARDS;

S 11 195 10 694 95 11

S 21 894 10 294 45 1 1 1

S 31 194 14 111 1

H 20 1

H 41 895 21 294 30 194 71 11

H 61 394 901193 7 1

H 911094 2 111111 11

D 11 190 7 1

D 21 294400 1 1111

D 30

C 11 195 201294 71094 14111

C 211094 7 694 30 1 1

C 50 1

C 611294 31094 14 794 601 1

;

 

 

PROC FORMAT CNTLOUT=new.lecfe1f;

VALUE YNF 1="Yes"

0="No"

.="No";

PROC CONTENTS DATA=new.lecfe1;

PROC PRINT DATA=new.lecfe1 split="*";

ID a1 a2;

FORMAT a3 a5a a5b a5c a5d a5e a5f a5g a5h a5i a5j ynf.;

RUN;

 

 

Listing of SAS program for Part 3.

 

OPTIONS LS=128 PS=60 NODATE NONUMBER NOCENTER;

*P****************************************************************************;

*P*lecfep2.SAS 12/13/95 c691f #5 Ed Stanek *;

*P* DESCRIPTION: Create combined data with years smoking*;

*P* from baseline and 18 month data sets for question *;

*P* two in final 1995 *;

*P*Z* lecfe2.sd2 Combined data from baseline and 18 month *;

*P*Z* with re-computed years smoking *;

*P*Z* created from: lec11d4.sd2 baseline data *;

*P*Z* and lec11d8.sd2 18 mth data *;

*P*Z* created by lecfep2.sas *;

***************************************************************************;

LIBNAME old4 V604 "c:\sph\" ;

LIBNAME new V610 "c:\sph" ;

 

DATA base (DROP=vdate cigs_d);

SET new.lec11d4;

 

DATA m18 (DROP=cigs_d);

SET new.lec11d8;

LABEL vdate="18Mth*Visit*Date:*VDATE";

 

PROC SORT data=base; BY ID;

PROC SORT data=m18; BY ID;

DATA lecfe2;

MERGE base m18;

BY id;

**********************************;

*** Create years smoked variable *;

**********************************;

*** Set 18 mth visit date=12/1/94 ;

*** when missing ;

**********************************;

IF vdate=. THEN vdate=mdy(12,1,94);

******************************************;

*** Calculate years smoking from birth *;

*** date, age at start, and 18 mth visit *;

*** date *;

******************************************;

yrsmok=(vdate-(dob+365.25*s_age))/365.25;

******************************************;

*** Calculate average of years smoked when*;

*** subject did not quit smoking *;

IF quit NE 1 THEN f_yrsm=INT(MEAN(yrsmok, t_smoke));

ELSE f_yrsm=t_smoke;

LABEL yrsmok="Baseline*Calculate*Yrs*Smoked:*yrsmok"

f_yrsm="Final*Estimated*Yrs*Smoked:*f_yrsm";

LENGTH f_yrsm 3;

 

PROC SORT DATA=lecfe2;

BY f_yrsm;

PROC PRINT SPLIT="*" DATA=lecfe2;

ID id;

VAR yrsmok t_smoke f_yrsm quit;

TITLE1 "Listing of Years Smoked for Subjects";

 

DATA new.lecfe2 (Label="SAS data with Smoking Years: LECFE2.SAS);

SET lecfe2;

RUN;

 

Listing of Program for Part 4.

 

OPTIONS LS=128 PS=60 NODATE NONUMBER NOCENTER;

*P****************************************************************************;

*P*lecfep3.SAS 12/13/95 c691f #5 Ed Stanek *;

*P* DESCRIPTION: Combine data on years smoked with *;

*P* additional data, and tabulate results for important*;

*P* reasons *;

*P* lecfe2.sd2 Combined data from baseline and 18 month *;

*P* with re-computed years smoking *;

*P* lecfe1.sd2 Additional data at 18 months *;

***************************************************************************;

LIBNAME old4 V604 "c:\sph\" ;

LIBNAME new V610 "c:\sph" ;

**************************************************;

*** create common variables to combine data and *;

*** grouping variable for smoking duration *;

**************************************************;

 

DATA add (KEEP=city subject a5a a5b a5c a5c a5e a5f a5g

a5h a5i a5j);

SET new.lecfe1;

city=a1;

subject=a2;

**************************************;

*** Recode values to 0 if missing **;

**************************************;

ARRAY x{10} a5a a5b a5c a5c a5e a5f a5g a5h a5i a5j;

DO i=1 to 10;

IF x{i}=. THEN x{i}=0;

END;

 

DATA lecfe2 (KEEP=city subject f_yrsm f_yrsm1);

SET new.lecfe2;

***************************;

*** Create City and ID vars;

***************************;

city=substr(id,1,1);

subject=.;

subject=substr(id,2,4);

********************************;

*** categorize yrs smoked **;

********************************;

IF 0 LE f_yrsm LT 30 THEN f_yrsm1=0;

IF 30 LE f_yrsm THEN f_yrsm1=1;

LENGTH f_yrsm1 3;

LABEL f_yrsm1="Smoked*30+yrs?:*:F_YRSM1";

PROC FORMAT;

VALUE f_yrsm1f 0="No"

1="Yes";

 

**************************************;

*** Combine data **;

**************************************;

PROC SORT DATA=add; BY city subject;

PROC SORT DATA=lecfe2; BY city subject;

DATA both;

MERGE add lecfe2;

BY city subject;

FORMAT f_yrsm1 f_yrsm1f.;

 

PROC FREQ;

tables f_yrsm1;

TITLE1 "Number of subjects Smoking for Less than and GE 30 Years";

PROC TABULATE DATA=both;

CLASS f_yrsm1;

VAR a5a a5b a5c a5c a5e a5f a5g a5h a5i a5j;

TABLES a5a a5b a5c a5c a5e a5f a5g a5h a5i a5j,(f_yrsm1)*(MEAN);

KEYLABEL mean="Prop. Important";

TITLE1 "Summary of Proportion of Subjects considering Factors Important to Quit Smoking by Years smoked";

RUN;

 

 

Listing of Program for Part 5.

 

OPTIONS LS=128 PS=60 NODATE NONUMBER NOCENTER;

*P****************************************************************************;

*P*lecfep4.SAS 12/13/95 c691f #5 Ed Stanek *;

*P* DESCRIPTION: Calculate the number of smoke free *;

*P* days in the past year for subjects using additional*;

*P* data *;

*P* lecfe1.sd2 Additional data at 18 months *;

***************************************************************************;

LIBNAME old4 V604 "c:\sph\" ;

LIBNAME new V610 "c:\sph" ;

**************************************************;

*** create common variables to combine data and *;

*** grouping variable for smoking duration *;

**************************************************;

 

DATA add (KEEP=city subject

A4A1 A4A2 A4A3 A4B1 A4B2 A4B3 A4C1 A4C2 A4C3);

SET new.lecfe1;

city=a1;

subject=a2;

 

DATA lecfe2 (KEEP=city subject vdate);

SET new.lecfe2;

***************************;

*** Create City and ID vars;

***************************;

city=substr(id,1,1);

subject=.;

subject=substr(id,2,4);

PROC SORT DATA=add; BY city subject;

PROC SORT DATA=lecfe2; BY city subject;

DATA both;

MERGE add lecfe2;

BY city subject;

**********************************************;

*** Create quit start days and compute days in;

*** and out of 365 day period ;

*** for one calendar year ;

**********************************************;

*********************************************;

*** First and last days of the 365 day period;

*********************************************;

daya=vdate-364; *first day in 365 day period;

dayb=vdate; *last day in 365 day period;

*********************************************;

*** calculations for Most recent quit period*;

*********************************************;

*****************************************;

*** Determine 1st quit day and last quit*;

*** day *;

*****************************************;

 

fq1=mdy(a4a1,15,a4a2); *day first quit smoking for most recent quit period;

lq1=fq1+a4a3-1; *last quit day for most recent quit period;

*******************************************;

*** Reset first and last days if outside *;

*** one year interval *;

*******************************************;

IF fq1 LT daya THEN fq1f=daya;

ELSE fq1f=fq1;

IF lq1 GT dayb THEN lq1f=dayb;

ELSE lq1f=lq1;

********************************************;

*** Calculate quit days in the 1 year period;

*** setting negative days to 0 ;

********************************************;

day1=lq1f-fq1f+1;

if day1 le 0 then day1=0;

 

 

**************************************************;

*** calculations for 2nd Most recent quit period*;

**************************************************;

*****************************************;

*** Determine 1st quit day and last quit*;

*** day *;

*****************************************;

fq2=mdy(a4b1,15,a4b2); *day first quit smoking;

lq2=fq2+a4b3-1; *last quit day;

*******************************************;

*** Reset first and last days if outside *;

*** one year interval *;

*******************************************;

IF fq2 LT daya THEN fq2f=daya;

ELSE fq2f=fq2;

IF lq2 GT dayb THEN lq2f=dayb;

ELSE lq2f=lq2;

********************************************;

*** Calculate quit days in the 1 year period;

*** setting negative days to 0 ;

********************************************;

day2=lq2f-fq2f+1;

if day2 le 0 then day2=0;

 

*************************************************;

*** calculations for 3rd most recent quit period*;

*************************************************;

*****************************************;

*** Determine 1st quit day and last quit*;

*** day *;

*****************************************;

 

fq3=mdy(a4c1,15,a4c2); *day first quit smoking;

lq3=fq3+a4c3-1; *last quit day ;

*******************************************;

*** Reset first and last days if outside *;

*** one year interval *;

*******************************************;

IF fq3 LT daya THEN fq3f=daya;

ELSE fq3f=fq3;

IF lq3 GT dayb THEN lq3f=dayb;

ELSE lq3f=lq3;

********************************************;

*** Calculate quit days in the 1 year period;

*** setting negative days to 0 ;

********************************************;

day3=lq3f-fq3f+1;

if day3 le 0 then day3=0;

sfree=day1+day2+day3;

 

************************************************;

*** categorize smoke free days for chart *;

*** setting categories= -1 none *;

*** 1-7 = 0 *;

*** 8-14 = 1 *;

*** etc *;

************************************************;

csfree=int((sfree+6)/7)-1;

LABEL sfree="Days*Smoke*Free:*sfree"

csfree="Weeks*smoke*free:*csfree";

 

PROC SORT;

BY sfree;

 

PROC PRINT SPLIT="*";

ID city subject;

VAR day1 day2 day3 sfree;

TITLE1 "List of Smoke Free Days in Past Year";

 

PROC CHART ;

HBAR csfree /LEVELS=52;

TITLE1 "Frequency Distribution of Smoke Free Weeks in Past Year";

TITLE2 " Note: -1 indicates no smoke free days";

RUN;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Last Update: 3/16/99
Comments: Ed Stanek
Email:
stanek@schoolph.umass.edu
\ed\web\be691f\webready\fe95d1.html