12-23-2021
Paakay
Calcite | Level 5
Member since
04-12-2016
- 8 Posts
- 0 Likes Given
- 0 Solutions
- 0 Likes Received
-
Latest posts by Paakay
Subject Views Posted 466 12-23-2021 07:13 AM 351 12-22-2021 08:59 PM 1121 12-22-2021 04:21 PM 556 06-01-2021 02:47 PM 749 06-01-2021 11:40 AM 751 06-01-2021 11:38 AM 887 05-14-2021 06:58 AM 395 05-14-2021 06:23 AM -
Activity Feed for Paakay
- Posted Dynamically replace missing character after last non missing character for each id on SAS Programming. 12-23-2021 07:13 AM
- Posted Replace missing characters with last non missing character multiple id's. on SAS Programming. 12-22-2021 08:59 PM
- Posted Dynamically create Fiscal Year and Quarters variable for repeated ids on SAS Programming. 12-22-2021 04:21 PM
- Posted Create Flags for Consecutive and Non Consecutive Flags on SAS Programming. 06-01-2021 02:47 PM
- Posted Re: Keep only Consecutuive flags in consecutive cycles on SAS Programming. 06-01-2021 11:40 AM
- Posted Re: Keep only Consecutuive flags in consecutive cycles on SAS Programming. 06-01-2021 11:38 AM
- Posted Keep only Consecutuive flags in consecutive cycles on SAS Programming. 05-14-2021 06:58 AM
- Posted Consecutive flags in consecutive cycles on SAS Programming. 05-14-2021 06:23 AM
12-23-2021
07:13 AM
Hi, I want to dynamically replace all missing characters after the last non missing character with the last non missing character for each member id.Example member_id 1 in FY 2018 , Qtr 4 , since comment is missing, it should be replaced with the last non missing comment which is 'abc'. For member_id 2, sine comment is missing for FY 2018, Qtrs 3 and 4, they should be replaced by 'def' . For member_id 3, since comment is missing for FY2018, Qtrs 2,3 and4, they would be replaced with 'ghi' Could some help me out. Sample data is below Data have;
input member_id FY Qtr Comment $12.;
datalines;
1 2018 1
1 2018 2
1 2018 3 'abc'
1 2018 4
2 2018 1
2 2018 2 'def'
2 2018 3
2 2018 4
3 2018 1 'ghi'
3 2018 2
3 2018 3
3 2018 4
;
run; This is what I want. Data want;
input member_id FY Qtr Comment $12.;
datalines;
1 2018 1
1 2018 2
1 2018 3 'abc'
1 2018 4 'abc'
2 2018 1
2 2018 2 'def'
2 2018 3 'def'
2 2018 4 'def'
3 2018 1 'ghi'
3 2018 2 'ghi'
3 2018 3 'ghi'
3 2018 4 'ghi'
;
run;
... View more
12-22-2021
08:59 PM
Hello All, I am writing a code to replace all missing charcters after the last non missing character with the last non missing character by member id but my code replaces all member ids with the first member id's last non missing character . Each member id is in the data 16 times. Can someone help me on how the code should break once it encounters a new member id and use the new member id's last non missing character to populate all missing characters after the last non-missing character ? I tried the code below by doesn't work. I want to replace the missing characters after the last non missing character with the last non missing character. For example for id 1, missing character after 2019 quarter 1 will have 'abc'. For id 2, missing character after 2018, 4th quarter will have 'ghi' .Snippet of my code is below but it doesn't work.. Your help is appreciated Data want;
input ID FY Qtr Missing_Char $3.
datalines;
1 2018 1 ''
1 2018 2 ''
1 2018 3 ''
1 2018 4 ''
1 2019 1 abc
1 2019 2 ''
1 2019 3 ''
2 2018 1 abc
2 2018 2 ''
2 2018 3 def
2 2018 4 ghi
2 2019 1 ''
2 2019 2 ''
2 2019 3 ''
3 2019 4 ''
;
run Data chk;
set want;
by id ;
retain missing_char;
if not missing(missing_char) then _missing_char=missing_char;
else missing_char=_missing_char;
_drop missing_char;
run;
... View more
12-22-2021
04:21 PM
Hi, I want to dynamically create Fiscal Year variable and Quarter for each repeated id in a dataset. There are 144,272 records. Each id is repeated 16 times in the dataset. So first four records for id 1 will be assigned Fiscal Year 2018 and assigned Quarter for 1 for first record, Quarter 2 for second record, Quarter three for third record snd Quarter 4 for the fourth record. Records 5 to 8 for id 1 will be assigned Fiscal Year 2019 and 5th record will be assigned Quarter1, 6th record Quarter 2, 7th record Quarter3 and 8th record Quarter4. I want to generate the Fiscal and Quarter variable dynamically for all records. Can someone help me out. The sas code below produces the output I want. Data have;
input id Fiscal_Year Quarter;
datalines;
1 2018 1
1 2018 2
1 2018 3
1 2018 4
1 2019 1
1 2019 2
1 2019 3
1 2019 4
1 2020 1
1 2020 2
1 2020 3
1 2020 4
1 2021 1
1 2021 2
1 2021 3
1 2021 4
;
run
... View more
06-01-2021
02:47 PM
Hello All, I want to flag ID's with consecutive flags as 1 and those without consecutive flags as 0. For example ID 1 is consecutive because it starts from cycle 1 to cycle 4 so I create a flag for ID 1 as 1. However for ID's with no consecutive cycle numbers like ID 2 (its starts from cycle 2 to cycle 5, missing cycle 1) and ID 3 also starts from cycle 8 missing cycles 1-7, I flags these ID's as 0. Is there a way to go about this. Thank you. Data have;
input ID $1. Cycle;
Datalines;
1 1
1 1
1 2
1 3
1 4
2 3
2 4
2 5
3 8
3 8
;
run;
... View more
06-01-2021
11:40 AM
Thanks Ksharp. That works but there was problem . What if I want to flag ID's with consecutive flags as 1 and those without consecutive flags as 0. For example ID 1 is consecutive because it starts from cycle 1 to cycle 4 so I create a flag for ID 1 as 1. However for ID's with no consecutive cycle numbers like ID 2 (its starts from cycle 2 to cycle 5, missing cycle 1) and ID 3 also starts from cycle 8 missing cycles 1-7, I flags these ID's as 0. Is there a way to go about this. Thanks you. Data have;
input ID $1. Cycle;
Datalines;
1 1
1 1
1 2
1 3
1 4
2 3
2 4
2 5
3 8
3 8
;
run;
... View more
06-01-2021
11:38 AM
Thanks Eriklund. That works but there was problem . What if I want to flag ID's with consecutive flags as 1 and those without consecutive flags as 0. For example ID 1 is consecutive because it starts from cycle 1 to cycle 4 so I create a flag for ID 1 as 1. However for ID's with no consecutive cycle numbers like ID 2 (its starts from cycle 2 to cycle 5, missing cycle 1) and ID 3 also starts from cycle 8 missing cycles 1-7, I flags these ID's as 0. Is there a way to go about this. Thanks you. Data have;
input ID $1. Cycle;
Datalines;
1 1
1 1
1 2
1 3
1 4
2 3
2 4
2 5
3 8
3 8
;
run;
... View more
05-14-2021
06:58 AM
I have ID's with multiple flags in cycles however some id's flags are not consecutive. For example ID A has two flags in cycle 1 but none in cycle 2,3,4 but then has another flag in cycle 5. I want to keep only the flags in cycle 1 and delete flags in cycle 5 since there is a break in cycle at 2. Another example is ID B has flags in cycles 1, 2,3 but not in cycle 4 however has flags in cycles 5 and 6. Since there is a break in cycle at 4, I want to keep the consecutive flags in cycles 1,2,3 and delete cycles 5 and 6. Can someone help me with this. Thank you. Sample data is below DATA chk;
INPUT ID $ Flag Cycle ;
CARDS;
A 1 1
A 1 1
A 1 5
A 1 5
B 1 1
B 1 2
B 1 3
B 1 5
B 1 6
C 1 1
C 1 1
C 1 2
C 1 4
C 1 5
;
RUN; Output Data should look like this Data chk2;
INPUT ID $ Flag Cycle ;
CARDS;
A 1 1
A 1 1
B 1 1
B 1 2
B 1 3
C 1 1
C 1 1
C 1 2
;
RUN;
... View more
05-14-2021
06:23 AM
I have ID's with multiple flags in cycles however some id's flags are not consecutive. For example ID A has two flags in cycle 1 but none in cycle 2,3,4 but then has another flag in cycle 5. I want to keep only the flags in cycle 1 and delete flags in cycle 5 since there is a break in cycle at 2. Another example is ID B has flags in cycles 1, 2,3 but not in cycle 4 however has flags in cycles 5 and 6. Since there is a break in cycle at 4, I want to keep the consecutive flags in cycles 1,2,3 and delete cycles 5 and 6. Can someone help me with this. Sample data is below DATA chk; INPUT ID $ Flag Cycle ; CARDS; A 1 1 A 1 1 A 1 5 A 1 5 B 1 1 B 1 2 B 1 3 B 1 5 B 1 6 C 1 1 C 1 1 C 1 2 C 1 4 C 1 5 ; RUN; This is the output I want ID. FLG CYC 1 A 1 1 2 A 1 1 3 B 1 1 4 B 1 2 5 B 1 3 6 C 1 1 7 C 1 1 8 C 1 2
... View more