BookmarkSubscribeRSS Feed
112211
Obsidian | Level 7

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

7 REPLIES 7
whymath
Lapis Lazuli | Level 10
Why you want to flag these observations? What is the rule?
PaigeMiller
Diamond | Level 26

Please explain why these records are flagged. Please explain the logic by which these records are flagged. Please explain more.

--
Paige Miller
ballardw
Super User

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.

Tom
Super User Tom
Super User

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.

Tom_0-1718983174466.pngTom_1-1718983187053.png

 

112211
Obsidian | Level 7

 

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
Kurt_Bremser
Super User
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;
Astounding
PROC Star
To do anything with this data, it would be wise to first fix the INPUT statement. It reads the wrong columns.

Also, read dates as dates. There's no advantage to reading them as text.

Post again, if you don't know what any of this means.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 740 views
  • 0 likes
  • 7 in conversation