Data pmr ;
input patient$ cpevent$10-18 fatestcd$19-26 faresdtc$28-37 FAOBJ$;
cards ;
100102 baseline occur 29oct2021 A
100102 baseline symstdt 29oct2021 A
100102 baseline symendt A
100102 week1 occur A
100102 week1 symstdt 29oct2021 A
100102 week1 symendt A
100102 week2 occur A
100102 week2 symstdt 27oct2021 A
100102 week2 symendt A
100102 week3 occur A
100102 week3 symstdt 29oct2021 A
100102 week3 symendt 19oct2021 A
100102 week4 occur A
100102 week4 symstdt A
100102 week4 symendt A
100102 week5 occur A
100102 week5 symstdt 30oct2021 A
100102 week5 symendt 19oct2021 A
100103 baseline occur A
100103 baseline symstdt 29oct2021 A
100103 baseline symendt A
100103 week1 occur A
100103 week1 symstdt 28oct2021 A
100103 week1 symendt A
100103 week2 occur A
100103 week2 symstdt 28oct2021 A
100103 week2 symendt A
100103 week3 occur A
100103 week3 symstdt 29oct2021 A
100103 week3 symendt 19oct2021 A
100103 week4 occur A
100103 week4 symstdt A
100103 week4 symendt A
100103 week5 occur A
100103 week5 symstdt 30oct2021 A
100103 week5 symendt 19oct2021 A
;
I need flag = "Y" for following BY USING above data
1) 100102 week2 symstdt 27oct2021 A
2) 100103 week1 symstdt 28oct2021 A
3)100103 week2 symstdt 28oct2021 A
Like above i have more than 800 records are there so please anyone help me with programming
1)We need to see the baseline visit date matching with the remaining visits if not then it should be flagged.
2) and if the subject has the same baseline date at symstdt and symendt(different) no flag.
3) if same subject has symstdt and symendt then also no flag
Please explain why these records are flagged. Please explain the logic by which these records are flagged. Please explain more.
If you want working code you want to repost your data step code in a text box. The forum software reformats text pasted into the main message windows and when I copied your code, pasted into my SAS editor and ran it I get values of "seline" and "ek 1" "ek 2" for cpevent and things like "dt 29o" and nothing that looks like "date" for the Farescdtc variable. The forum combines some white space characters to a single one so the column postions change and mixes of spaces and tabs can get truly hard to guess where the forum places the resutls.
Open a text box using the </> icon that appears above the message window and paste the code into the box.
Just for giggles, why is your supposed date information read into character variable?? Almost any use of date values, such as looking for before/after, is next to impossible with character values. Even your request for difference had issues if there are mixes of case such as 29Oct2021 is not the same as 29oct2021 when doing a character comparison.
Not sure what you are trying to flag. It might be easier to explain (and perhaps also to code) if you transposed the data. Either to make separate variables for the FASTESCD or CPEVENT.
data pmr;
input patient $ cpevent $10-18 fatestcd $19-26 faresdtc $28-37 FAOBJ $;
cards;
100102 baseline occur 29oct2021 A
100102 baseline symstdt 29oct2021 A
100102 baseline symendt A
100102 week1 occur A
100102 week1 symstdt 29oct2021 A
100102 week1 symendt A
100102 week2 occur A
100102 week2 symstdt 27oct2021 A
100102 week2 symendt A
100102 week3 occur A
100102 week3 symstdt 29oct2021 A
100102 week3 symendt 19oct2021 A
100102 week4 occur A
100102 week4 symstdt A
100102 week4 symendt A
100102 week5 occur A
100102 week5 symstdt 30oct2021 A
100102 week5 symendt 19oct2021 A
100103 baseline occur A
100103 baseline symstdt 29oct2021 A
100103 baseline symendt A
100103 week1 occur A
100103 week1 symstdt 28oct2021 A
100103 week1 symendt A
100103 week2 occur A
100103 week2 symstdt 28oct2021 A
100103 week2 symendt A
100103 week3 occur A
100103 week3 symstdt 29oct2021 A
100103 week3 symendt 19oct2021 A
100103 week4 occur A
100103 week4 symstdt A
100103 week4 symendt A
100103 week5 occur A
100103 week5 symstdt 30oct2021 A
100103 week5 symendt 19oct2021 A
;
run;
I need flag = "Y" for following BY USING above data
1) 100102 week2 symstdt 27oct2021 A
2) 100103 week1 symstdt 28oct2021 A
3)100103 week2 symstdt 28oct2021 A
Like above i have more than 800 records are there so please anyone help me with programming
1)We need to see the baseline visit date matching with the remaining visits if not then it should be flagged.
2) and if the subject has the same baseline date at symstdt and symendt(different) no flag.
3) if same subject has symstdt and symendt then also no flag
proc transpose data=pmr out=pmr2;
by patient cpevent;
id fatestcd;
var faresdtc;
run;
data want;
set pmr2;
by patient;
retain _symstdt;
if first.patient
then _symstdt = symstdt;
else if missing(symendt) and symstdt ne _symstdt then flag = "Y";
drop _name_ _symstdt;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.