BookmarkSubscribeRSS Feed
Quartz | Level 8
Code Date
A1 4/30/2010
B1 5/16/2010
C1 5/30/2010
D1 6/16/2010
E1 4/30/2010

How to display only those codes that are 4 weeks apart from each other?
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Use a DATA step to read-up the data, then use the LAG function and also use INTCK to compute delta/difference between consecutive observations.

Scott Barry
SBBWorks, Inc.
Jade | Level 19
This might get you started.

data test;
input Code:$2. Date:mmddyy.;
format date mmddyy10.;
A1 4/30/2010
B1 5/16/2010
C1 5/30/2010
D1 6/16/2010
E1 4/30/2010
proc distance method=EUCLID out=dist shape=square;
id code;
var interval(date);
proc print;

It produces this output.

Obs Code A1 B1 C1 D1 E1

1 A1 0 16 30 47 0
2 B1 16 0 14 31 16
3 C1 30 14 0 17 30
4 D1 47 31 17 0 47
5 E1 0 16 30 47 0
Quartz | Level 8
Matrix form of output gives a good idea of the spread of the interval.Thanks a lot.
Quartz | Level 8
if we are to output the number of weeks instead of days?
Rhodochrosite | Level 12
cartesian join or reflex join are terms to describe "every-way" join
why not do all the work your self with an sql step
, like (to create the list of code pairs that are 4 weeks apart)
/* interval between dates measured in weeks*/[pre]
select a.code as code_a
, b.code as code_b
, as date_a
, as date_b
, from data a, data b
where range(, =between 3.5 and 4.49 [/pre]
or something like that (depending on the "precision" of 4 weeks)

if you just want counts of the code_a, code_b pairs then
use count(*) instead of, in the "select columns list" and group by
code_a, code_b


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 4 in conversation