I have duplicates by mrn
i want no duplicates by mrn as shown below and wanted everything to be fitted in a single row
Is that possible?????
Thanks
Hi I have
mrn in1 out1 in2 out2 in3 out3
101 time1 time3 time5
101 time2 time4 time6
I want
mrn in1 out1 in2 out2 in3 out3
101 time1 time2 time3 time4 time5 time6
An easy way:
data want;
update have (obs=0) have;
by mrn;
run;
But if you're going to want to understand the tools and how they work, you are better off studying Reeza's link. Those tools are more important than this program. Good luck.
Ooops ... Looks like I'm a little slow on the draw today!
Yes it is possible, look up retain and lag.
http://changchung.com/download/retainLagLeadInterleave_draft.pdf
An easy way:
data want;
update have (obs=0) have;
by mrn;
run;
But if you're going to want to understand the tools and how they work, you are better off studying Reeza's link. Those tools are more important than this program. Good luck.
Ooops ... Looks like I'm a little slow on the draw today!
"Ooops ... Looks like I'm a little slow on the draw today!"
Not anymore. Your post has more information, deserves "shoot and kill".
Haikuo
Thanks so much for the help..
Why is the obs=0 used
and why only for one of the two have datasets????
Regards
If you're confident that you understand how the UPDATE statement works, I can answer that. But if not, you are better off studying other tools such as Reeza's link.
Yes I do..
It updates the dataset with the by variable...
so if there is missing out1 in the first dataset (101) and i the second dataset (101) has a value then
it updates the inforamtion
OK, so the first data set is the master list and cannot have any duplicated MRNs. The second data set can have multiple observations per MRN. Any MRN in the second data but not in the first automatically gets added to the final data set.
The UPDATE statement requires both data set names (master first, transaction second). So obs=0 just creates an empty master data set, but with exactly the same variable definitions as in the transaction data set. The name of a master data set is required by UPDATE, but it doesn't have to actually hold any data. All the data will come from the transaction data set.
Thanks so much..
Reezas notes was helpful too..But I did not know which part of that notes is useful..
Great Help
Actually I am always late due to in another time zone.
To OP, If you cann't understand what UPDATE is doing, and your variables are all numeric. Here is a more explicit way you might see .
proc means data=have;
by mrn;
var in: out: ;
output out=want sum= ;
run;
Ksharp
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: