I have data that I am trying to transform in order to create a SAS visual. There are several steps before arriving there. I have exported a few lines of data as an xlsx file and attached here.
A typical line of data is like (I have chosen just the important fields)
Case Date Contact_ID Date1
234243 01MAR2020 51954633 03SEP2020
716432 02MAR2020 53426754 03SEP2020
and so on
The date values are formatted as date9. I want to split then by day, month, year so I tried the following
Data SASCHART.Date_Fix;
set SASCHART.Cases_Contacts_Want;
Yr_1 = substr(Date,6,4);
Mon_1= substr(Date,3,5);
Day_1 = substr(Date,1,2);
Daymon_1=trim(Day_1||Mon_1);
Yr_2 = substr(Date1,6,4);
Mon_2= substr(Date1,3,5);
Day_2 = substr(Date1,1,2);
Daymon_2=trim(Day_2||Mon_2);
run;
which didn't produce the result I need which is
Daymon_1 Daymon_2
01MAR 03SEP
and so on. So I looked in some older SAS Communities posts and tried something like this
Data SASCHART.Date_Fix;
set SASCHART.Cases_Contacts_Want;
new_date_1 = mdy(substr(Date,3,5), substr(Date,1,2), substr(Date,6,4));
format new_date_1 YYMMDD8.;
run;
That didn't work either.
I want to count the number of Cases for each daymon_1 and the number of contact_ID by daymon_2. It may be something like cases contacts
date count date count
01MAR 1 01SEP 38
. .
. .
26OCT 834 16OCT 543
Then I will use the dates on an x-axis and the counts on the y-axis to create an overlaid line graph in SAS. The cases started earlier than contact-tracing and are several days ahead of the contact counts, since contacting_tracing is slowing down for several reasons.
First, I need to split the dates into substrings properly.
Your expertise is very much appreciated.
wlierman
... View more