I’ve hit a graphing requirement that I'm not quite sure how to tackle in VA 8.3. I’m hoping someone here can point me to an example or tutorial that covers a similar problem in an efficient manner. I have a data set similar to the following:
RequestID PersonID StartDate EndDate
1 1 1Jan21 10Jan21
2 2 5Jan21 5Feb21
3 1 20Jan21 1Mar21
I’m trying to create a simple line chart where the x axis is each day of the time period 1Jan21-1Mar21 (min value of StartDate through max value of EndDate). The Y axis is the number of people active, meaning people where the day is between StartDate and EndDate.
To accomplish this goal, I’ve been preparing my data by joining the main data set with another table that has a row for each day of my time period on the condition Day between StartDate and EndDate. This greatly increases the size of my dataset from about 6,000 rows to over 500,000 and slows things down. Is there a way to accomplish this in VA without joining the second table?
Thanks for your insight,
David
Hello,
I wouldn't know how to do that in Visual Analytics, but if you are preparing your data anyway, ... why don't you prepare fully to have a dataset with one row per date?
The program below is only correct if the time ranges for the same person do not overlap.
data have1;
input RequestID PersonID StartDate : ANYDTDTE9. EndDate : ANYDTDTE9.;
format StartDate EndDate date9.;
datalines;
1 1 01Jan2021 10Jan2021
2 2 05Jan2021 05Feb2021
3 1 20Jan2021 01Mar2021
;
run;
data have2(drop=StartDate EndDate);
set have1;
do MYDATE=StartDate to EndDate;
output;
end;
format MYDATE date9.;
run;
PROC FREQ data=have2 noprint;
tables MYDATE / out=WANT_count_MYDATE;
format MYDATE date9.;
run;
/* end of program */
Kind regards,
Koen
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.