Hello there
I have the following data and would like to keep the children's records where:
surgicalindex = 1 --> easy part
command used:
keep if surgicalindex == 1
& (which is where my problem lies) :
all the episodeno preceeding surgicalindex == 1
As the episodeno may vary for each IDno can you recommend any syntax?
(assuming the dataset if over 500 records - this is only a snapshot, so I can not individually write the episodeno... as there are over 500 records with various associated episode nos.
I tried:
keep if admidate <= surgicalindex == 1
But I clearly I'm writing adequately for stata to understand me as I am left with only 1 record.
I would like to see the following kept (red) and the black dropped as the surgicalindex != 1 and the admidate is > the admidate of surgicalindex = 1 for Idno child 2
Can you recommend appropriate syntax/commands?
I have the following data and would like to keep the children's records where:
surgicalindex = 1 --> easy part
command used:
keep if surgicalindex == 1
& (which is where my problem lies) :
all the episodeno preceeding surgicalindex == 1
As the episodeno may vary for each IDno can you recommend any syntax?
(assuming the dataset if over 500 records - this is only a snapshot, so I can not individually write the episodeno... as there are over 500 records with various associated episode nos.
I tried:
keep if admidate <= surgicalindex == 1
But I clearly I'm writing adequately for stata to understand me as I am left with only 1 record.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(dvt procedureid IDno MI surgicalindex episodeno admidate) 1 . 1 0 0 1 0 1 110 1 0 1 2 31 0 . 2 1 0 1 60 1 . 2 1 1 2 305 0 112 2 1 0 3 335 end format %td admidate
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float(dvt procedureid IDno MI surgicalindex episodeno admidate)
1 . 1 0 0 1 0
1 110 1 0 1 2 31
0 . 2 1 0 1 60
1 . 2 1 1 2 305
0 112 2 1 0 3 335
end
format %td admidate
Can you recommend appropriate syntax/commands?

Comment