Hi!
I am having some difficulty creating dummy variables for the months and also creating a table where i can see how many people were infected during a specific month. Below are the codes that i have so far
/* Dummy Variables*/
DATA work.import;
SET work.import;
IF MOI=4 THEN DUMMYMONTH2=1;
IF MOI=5 THEN DUMMYMONTH3=1; ELSE DUMMYMONTH3=0;
IF MOI=6 THEN DUMMYMONTH4=1; ELSE DUMMYMONTH4=0;
IF MOI=7 THEN DUMMYMONTH5=1; ELSE DUMMYMONTH5=0;
IF MOI=8 THEN DUMMYMONTH6=1; ELSE DUMMYMONTH6=0;
IF MOI=9 THEN DUMMYMONTH7=1; ELSE DUMMYMONTH7=0;
IF MOI=10 THEN DUMMYMONTH8=1; ELSE DUMMYMONTH8=0;
IF MOI=11 THEN DUMMYMONTH9=1; ELSE DUMMYMONTH9=0;
RUN;
PROC FREQ DATA=work.import;
TABLES DUMMYMONTH1*DUMMYMONTH2*DUMMYMONTH3*DUMMYMONTH4*DUMMYMONTH5*DUMMYMONTH6*DUMMYMONTH7*DUMMYMONTH8*DUMMYMONTH9/LIST;
RUN;
Creating dummy variables for this purpose is not necessary. You can simply use variable MOI in PROC FREQ. I point out that using a month number by itself gets somewhat sketchy if the months are from different years, as January of year 1 and January of year 2 would be considered to be the same month (is that what you want?)
But I am confused by your PROC FREQ. Do you really want the 9-way table of frquencies? That doesn't sound like the words you used to describe the output.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.