SAS macros to average between a range of dates with missing dates in the data -
I'm completely new to SAS and its macro. I have this dataset, whose name is mydata:
object symbol is DATE kx y 1a 20120128 5 6 2b 20120128 10 7 3C 20120128 20 9 4D 20120128 6 10 5 E 20120128 9 20 My problem is to find this function:
Newi = â ???? Ja ?? ¬ [-10, -2] (x + y) i, j / n, ou,
i = no random date (user defined) ) Total number of days with data available for (x + y) between N = (-10, -2) -10 and -2 (10 days or two days ago) = Dates may be missing in available data.
Can anyone help me with the possible SAS macros for the following problem?
Thanks in advance!
I assume that your date data is stored as dates and the numerical calculation is accepted Can do. I also believe that you want to get an average of X and Y for a specific date around D, where the D user has been defined. After all, I agree that if you have two unique IDs on the same day, then you first put it on a random one. Of course, those perceptions may need to be touched a bit, but what I believe is asking you (I admit that I only believe that I understand your question), hopefully That it is necessary that you can be comfortable with ease easily.
OK ...
in Process Suit Data; Date by unique; Run; % MACRO abbreviation (userdate); Data out; In SET (where = (date & gt; = & amp; userdate-10 and date & lt; = & amp; userdate - 2); BY unique unique; xy = sum (x, y) if first.uniqueid; RUN ; PROC summary data = out; out = average and user detenet MEAN (xy) =; run;% MEND summary;% compress ('20120128D); what's happening here ? Okay, I first and exclusively data before. I can use nodopagya, but I think how you can control duplicate antidepressants on a given date, it is controlled The dataset is throwing duplies by keeping that duplicate for the first time, but you can modify the dudupling logic (which is coming from BE command in the data phase and IF first is the same in the command).
If you want a set of dates around a specific user defined date, get D.Dr and filter the dataset with WHERE. You can do this in your PROC Sort step too, and so on Due to the fact that your raw data will be updated frequently, if you do not need to run sort every time the user defines a date range, keep it outside the macro and run it only when necessary. The type may be slow
In the data phase, I am getting the amount (X, Y) in the account that either X or Y disappears, or both, nor in those cases X + Y will be missing. I think now that you want, but keep in mind that we will make yoga (x, y) more than n, where n "either x or y are not missing." If you want to ignore those lines completely, use x + y and IF xy! = Add. In the data phase
The last part, yoga, should be very self-explanatory.
Hope it helps.
Comments
Post a Comment