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.
Answer / kumaraswamy maduri
data new;
date1="31Dec2008"d;
run;
data new1;
input date1 date9. subj;
cards;
31dec2008 1
30dec2008 1
30dec2008 2
31dec2008 2
;
run;
proc sort;by date1;run;
data comp;
merge new(in=x) new1;
by date1;
if x;
run;
I have used the above code. I got perfect results.
Please correct me if I misunderstood your question.
| Is This Answer Correct ? | 6 Yes | 0 No |
What is univariate n where it can be used n how...?
Hi , which book should i refer to for preaparing SAS statistical Exam. Searched a lot on books but still did n't find relevant books
What are the special input delimiters used in SAS?
What does the RUN statement do?
Difference between SAS STATA & SPSS?
how can you sort the dataset having millions of OBS(instead of sort procedure?
where are dashboard components are created and maintained? : Sas-bi
What is the use of stop statement?
Can we use where and having clauses in a single SAS program. ex: proc sql; select a,b,c from test where state in 'KA' and having <some condition>. Is the above program run correctly, if not why ?
what has been your most common programming mistake? : Sas programming
If you were told to create many records from one record, show how you would do this using array and with proc transpose?
What is the difference between an informat and a format. Name three informats or formats.