BookmarkSubscribeRSS Feed
Daisy808
Calcite | Level 5

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;

 

1 REPLY 1
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 796 views
  • 0 likes
  • 2 in conversation