_N_ gives the record number. You can access any record in
the dataset using _N_ if you know the record number. It is
set as 1 for the first record and incremented for every
subsequent record. It is an automatic variable and is not
visible when you open a dataset. This can also be used to
subset a data. For ex, if you want to access the first 100
records then you can say "if _N_ <= 100".
This is an automatic variable of PDV that returns the no of
observations that it has iterated.There are such variables
All these variables will not be displayed in the target output.
if _n_>=2 and <=6 then output;
Compiling time of the program in PDV automatically some
variables will generate, like _N_ and _Error_, _numeric_
_N_ will give the observation in the program. by default
_N_ value is 0, after compiling it will chage according to
the observations in the program.
I need help in merging two different datasets. I am merging
by date and I want to propagate observations from one
dataset to the corresponding dates. One dataset has a
unique date for each day of the month, while the other
dataset has same date for different patient visits. For
example I want to spread an observation on the 31DEC2008
from one dataset to several observations with the same date
on a second dataset for all the patients who visited on
that date. I have tried to merge the two and the result is
not what I wanted. Instead I get a dataset whereby all the
dates have missing values where observations from the first
datset should have spread.
What would the following datastep do?
Set Dist end=eof;
If EOF then
dimension is a macro variable that is being passed here
input dt account;
format dt date9.;
input startdt enddt total;
format startdt date9. enddt date9.;
1657 1834 12300
1557 1758 16800
1789 1789 12300
1788 1345 12383
1899 1899 13250
create table data3 as
select * from data1 as x left join data2 as y
on x.dt>=y.startdt and x.dt<=y.enddt;
Here, we are getting cartision product. But,I want left
join report consisting of this program. It should not get
duplicate values. you can modify the program also.