No merging required! What you need is a format.
Ultimately, you'll just write a short program like this:
*** Or, if you want ID to be numeric:
Now, how to make the MYFORMAT format?
For this you need the following:
proc format cntlin=<data set name>;
The data set in question can be generated from the one that contains the
FROM and TO variables now. For that, you'll have to read the manual,
though--under PROC FORMAT.
Johny Bravo wrote:
> Hi !
> I have a following problem.
> I have two datasets.
> First dataset contains numbers, e.g.:
> And second dataset that contains intervals, e.g.:
> id from to
> 1 1 3
> 2 4 23
> 3 26 500
> ... .... ....
> I want to classify all numbers from first dataset
> to intervals in the second. I want to have on output
> dataset that contains number and an ID of particular
> interval, e.g.:
> number ID
> 23 2
> 24 null
> 435 3
> 45 3
> ... ...
> ( BTW intervals in second set are separate)
> I am wondering how to do it with data step and maybe "retain".
> Maybe If-clause is nessesary, i don't know :(
> The main problem is how to join datasets with diffrent number
> of observations.
> Thanks in advance for advice,
> Best regards,
> Johny Bravo ;)