Coursera Assignment (Week 3)

Here’s the code for my week3 homework.

I have made a few necessary modifications in the variables that I am using in order to apply the data management steps, however, my research questions remains the same.

LIBNAME mydata “/courses/d1406ae5ba27fe300” access=readonly;
DATA new; set mydata.nesarc_pds;
LABEL S3AQ3B5=”frequency of chewing”
S3AQ8A6=”tried to stop more than once”
CHECK325=”tobacco use status”;
/* These are the labels which denotes the variables I have used in this program */
if S3AQ3B5=9 THEN S3AQ3B5=.;
/* if frequency is unknown then put null */
IF S3AQ8A6=9 THEN S3AQ8A6=.;
/* IF unknown if tried to sto[ but coundn’t do it*/
IF check325=2;
/*subsetting data to include only consumers with more than 1 year of use*/
IF CHECK325 NE 9 AND S3AQ8A6=. THEN S3AQ8A6=8;
/*(DECALSSIFYING THE VALID DATA)*/
PROC SORT; BY IDNUM;
PROC FREQ; TABLES S3AQ3B5 S3AQ8A6 CHECK325;
RUN;

And here are the output tables:

The FREQ Procedure

”frequency of chewing”
S3AQ3B5 Frequency Percent Cumulative
Frequency
Cumulative
Percent
Frequency Missing = 28
1 386 29.83 386 29.83
2 52 4.02 438 33.85
3 114 8.81 552 42.66
4 203 15.69 755 58.35
5 109 8.42 864 66.77
6 430 33.23 1294 100.00

”tried to stop more than once”
S3AQ8A6 Frequency Percent Cumulative
Frequency
Cumulative
Percent
1 576 43.57 576 43.57
2 742 56.13 1318 99.70
8 4 0.30 1322 100.00

”tobacco use status”
CHECK325 Frequency Percent Cumulative
Frequency
Cumulative
Percent
2 1322 100.00 1322 100.00

Explanation:

  • The output only consists of the candidates who are involved in tobacco chewing for more than 12 months (check325 set to 2)
  • Candidates who are not involved in tobacco chewing are marked as 8 in S3AQ8A6 TABLE instead of being missing.
  • Candidates who are not involved in tobacco chewing (blank for S3AQ3B5) are not included since only candidates with CHECK325=2 are selected.

 

SAS is not an easy language! 😛  Anyways, I hope all is good with you.

Until next time, goodbye! and Happy New Year

Kush

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s