I have a data set with many sas-date variables that represent dates on which certain events occured for each observation. If the event did not occur, the date variables are missing.
To count how many of the events occurred (and create a new variable with this information), I would simply use the N( var1, var2, varN...) function in a data step.
Now, if I need to count how many of these events occurred (i.e., how many variables have non-missing values) within a date range created by other variables, can I use the N function nested somehow in an if-then string? Is there another applicable function?
The data looks like this if my wording wasn't clear:
You have the INTCK function to consider. Also, you may want to consider a DO/END loop to check for dates within a low/high range -- consider that SAS numeric DATE variables are represented as "number of days since 1/1/1960".
Also, if all analysis is done within one observation, you can look at using your appropriate function, like N, and code this type of assignment statement:
4/12/98 5/15/98 4/14/98 5/26/98 4/30/98
startdate=12APR1998 enddate=15MAY1998 event1=14APR1998 event2=26MAY1998 event3=30APR1998 occur=3
_ERROR_=0 _INFILE_=4/12/98 5/15/98 4/14/98 5/26/98 4/30/98 _N_=1
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds