BookmarkSubscribeRSS Feed
David12345
Calcite | Level 5

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

1 REPLY 1
sbxkoenk
SAS Super FREQ

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Tips for filtering data sources in SAS Visual Analytics

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.

Discussion stats
  • 1 reply
  • 450 views
  • 2 likes
  • 2 in conversation