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*/
/*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;
And here are the output tables:
The FREQ Procedure
|”frequency of chewing”|
|Frequency Missing = 28|
|”tried to stop more than once”|
|”tobacco use status”|
- 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