sas

Drop observations once condition is met by multiple variables

允我心安 提交于 2021-02-10 23:27:29
问题 I have the following data and used one of the existing answered questions to solve my data problem but could not get what I want. Here is what I have in my data Amt1 is populated when the Evt_type is Fee Amt2 is populated when the Evt_type is REF1/REF2 I don't want to display any observations after the last Flag='Y' If there is no Flag='Y' then I want all the observations for that id (e.g. id=102) I want to display if the next row for that id is a Fee followed by REF1/REF2 after flag='Y' (e.g

SAS Macro Do LOOP

家住魔仙堡 提交于 2021-02-10 15:19:46
问题 I want to have a sas macro loop by even years, so the do loop would jump from 2006 to 2008 to 2010...all the way to 2018 and not from 2006 to 2007. When I do a %by = 2, SAS doesn't work and gives me an error message. What is the best solution? I have the following Code: %macro import; %do I = 2006 %to 2018; data BTI&I; set edited.Bti_&I; year=&I; run; %end; %mend import; %import; 回答1: Add the %by 2 keyword to increment intervals of 2. I would also recommend passing the start and end years as

SAS, sum by group

元气小坏坏 提交于 2021-02-10 09:15:28
问题 I want to calculate the sum by var1. Could you use two methods to do the calculation. SQL and data step with if first.var1. data have; input var1 var2$ var3; datalines; 1 a 3 1 a 4 1 a 3 2 b 5 2 b 3 3 c 1 ; run; data want; input var1 var2 $ var3 sum_by_var1; datalines; 1 a 3 10 1 a 4 10 1 a 3 10 2 b 5 9 2 b 3 9 3 c 1 9 ; run; my two ways: The code below works on this small data set, but I wonder if it will work on large data sets because it is hard to check the results. proc sql; create table

SAS, sum by group

余生长醉 提交于 2021-02-10 09:14:08
问题 I want to calculate the sum by var1. Could you use two methods to do the calculation. SQL and data step with if first.var1. data have; input var1 var2$ var3; datalines; 1 a 3 1 a 4 1 a 3 2 b 5 2 b 3 3 c 1 ; run; data want; input var1 var2 $ var3 sum_by_var1; datalines; 1 a 3 10 1 a 4 10 1 a 3 10 2 b 5 9 2 b 3 9 3 c 1 9 ; run; my two ways: The code below works on this small data set, but I wonder if it will work on large data sets because it is hard to check the results. proc sql; create table

SAS, sum by group

假如想象 提交于 2021-02-10 09:12:47
问题 I want to calculate the sum by var1. Could you use two methods to do the calculation. SQL and data step with if first.var1. data have; input var1 var2$ var3; datalines; 1 a 3 1 a 4 1 a 3 2 b 5 2 b 3 3 c 1 ; run; data want; input var1 var2 $ var3 sum_by_var1; datalines; 1 a 3 10 1 a 4 10 1 a 3 10 2 b 5 9 2 b 3 9 3 c 1 9 ; run; my two ways: The code below works on this small data set, but I wonder if it will work on large data sets because it is hard to check the results. proc sql; create table

SAS, sum by group

那年仲夏 提交于 2021-02-10 09:12:09
问题 I want to calculate the sum by var1. Could you use two methods to do the calculation. SQL and data step with if first.var1. data have; input var1 var2$ var3; datalines; 1 a 3 1 a 4 1 a 3 2 b 5 2 b 3 3 c 1 ; run; data want; input var1 var2 $ var3 sum_by_var1; datalines; 1 a 3 10 1 a 4 10 1 a 3 10 2 b 5 9 2 b 3 9 3 c 1 9 ; run; my two ways: The code below works on this small data set, but I wonder if it will work on large data sets because it is hard to check the results. proc sql; create table

SAS, sum by group

旧时模样 提交于 2021-02-10 09:11:35
问题 I want to calculate the sum by var1. Could you use two methods to do the calculation. SQL and data step with if first.var1. data have; input var1 var2$ var3; datalines; 1 a 3 1 a 4 1 a 3 2 b 5 2 b 3 3 c 1 ; run; data want; input var1 var2 $ var3 sum_by_var1; datalines; 1 a 3 10 1 a 4 10 1 a 3 10 2 b 5 9 2 b 3 9 3 c 1 9 ; run; my two ways: The code below works on this small data set, but I wonder if it will work on large data sets because it is hard to check the results. proc sql; create table

SAS Loop through list of macro variable

喜欢而已 提交于 2021-02-10 07:15:02
问题 First off, I'm new so I apologize if this is not a good question. I searched but did not find something similar. I'm not sure my approach is correct so any assistance would be appreciated. I'm working on a data set for a school that has semesters for example 2017SP is Spring of 2017, 2017SU is Summer of 2017 and so on. I have the following program where I set up a Macro Variable at the top and then use it to pull out the term from various libraries and data sets. Note that I have several data

SAS Loop through list of macro variable

天涯浪子 提交于 2021-02-10 07:14:37
问题 First off, I'm new so I apologize if this is not a good question. I searched but did not find something similar. I'm not sure my approach is correct so any assistance would be appreciated. I'm working on a data set for a school that has semesters for example 2017SP is Spring of 2017, 2017SU is Summer of 2017 and so on. I have the following program where I set up a Macro Variable at the top and then use it to pull out the term from various libraries and data sets. Note that I have several data

SAS Loop through list of macro variable

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-10 07:12:56
问题 First off, I'm new so I apologize if this is not a good question. I searched but did not find something similar. I'm not sure my approach is correct so any assistance would be appreciated. I'm working on a data set for a school that has semesters for example 2017SP is Spring of 2017, 2017SU is Summer of 2017 and so on. I have the following program where I set up a Macro Variable at the top and then use it to pull out the term from various libraries and data sets. Note that I have several data