Esteemed Advisers
I need some help with selectively deleting observations by groups. Below are exemplar “have”and “want” datasets. The goal is to retain only one Member that contains “A” in both the Alpha and Beta Groups (which one is retained is irrelevant as they are redundant).
Thanks for taking a look and any advice you have to offer,.
Gene
data have;
input Group $ Member $;
Alpha A1
Alpha A2
Alpha B1
Alpha B2
Alpha A3
Alpha C1
Alpha C2
Beta A1
Beta A2
Beta D1
Beta D2
Beta E1
Beta E2
Beta A3
;
data want;
input Group $ Member $;
Alpha A1
Alpha B1
Alpha B2
Alpha C1
Alpha C2
Beta A1
Beta D1
Beta D2
Beta E1
Beta E2
;
... View more
Hi Team, I am trying to created a counter (as per the expected results below). The data is sorted by Category Snapshot Focus_Date The rule is that expected result (a counter), where the focus_date is present is the difference in months, This I can do with an INTNX function. For the counter: When a new first.category arrives and the focus_date is blank I'd like the counter restarted at 0. If the next record is for the same category I'd like it to increase by 1. If for the same category a new focus_date is found, I can use the intnx function. However, then I'd like to restart the counter at 0 if there is no focus_date in the next line. If there have been no historic focus_date items yet, then the result should also be 0.. This is the code I tried without incorporating the intnx: data unique_months_2; set unique_months; by category snapshot focus_date; if first.category or lag(focus_date) <> focus_date then expected_result = 0; expected_result +1; run; My sample. Snapshot Category Focus_Date Expected Result 31-Mar-22 1 15-May-22 -2 30-Apr-22 1 15-May-22 -1 31-May-22 1 0 30-Jun-22 1 1 31-Jul-22 1 15-Jul-24 -24 31-Jan-23 2 0 28-Feb-23 2 15-Feb-23 -1 31-Mar-23 2 0 30-Apr-23 2 1 31-Aug-21 3 0 30-Sep-21 3 0 31-Oct-21 3 0 31-Mar-21 6 15-Mar-21 -1 30-Apr-21 6 0 31-May-21 6 20-May-21 -1 30-Jun-21 6 0 31-Oct-22 7 0 30-Nov-22 7 0 31-Dec-22 7 0 31-Dec-23 10 15-Jan-24 -2 31-Jan-24 10 15-Jan-24 -1 29-Feb-24 10 0 31-Mar-24 10 1 30-Apr-24 10 17-Apr-29 -60
... View more
macro generated code in the log from using the MPRINT option often appears as one long stream of continuous text. Is there a way to retain the indentation and hard returns from the original program code?
... View more
I have plotted the residuals against the predicted values for my multiple linear regression model. I'm uncertain whether my model exhibits heteroscedasticity. I conducted a Breusch-Pagan test, but since the MLR 4 assumption was not met, the results might be misleading. Could anyone help determine if there appears to be heteroscedasticity in this plot?
... View more
Hi there, I have googled similar questions but could not find answers that I can understand. So here I am asking for your help! What I want to know is how to get results separately in a group. Example (just copied and pasted from Excel) ID Weight Treatment kcal 1 NW A 400 2 NW A 500 3 OW A 560 4 NW A 800 5 OW A 490 6 NW A 500 7 OW A 400 8 OW A 700 9 NW A 900 1 NW B 580 2 NW B 600 3 OW B 800 4 NW B 500 5 OW B 600 6 NW B 800 7 OW B 700 8 OW B 500 9 NW B 780 1 NW C 570 2 NW C 670 3 OW C 570 4 NW C 400 5 OW C 600 6 NW C 800 7 OW C 800 8 OW C 500 9 NW C 800 In this example, I am going to run one-way repeated measures ANOVA to see if there is a treatment effect (A, B, C) on subsequent calorie intake (kcal). However, I want to see the result separately for each body weight status (NW=normal weight & OW=overweight). Please ignore the small sample size because this is just an example. In SPSS, we can "split file" and then get results for both NW and OW separately in any analysis conducted after that. I am an absolute beginner of SAS and have never edited the code. Just importing excel files for each analysis and selecting some commands. Therefore, I'd appreciate if you could explain in a comprehensive way if it involves code! TIA
... View more