Hi all, This one is quite frustrating. I want to return the Nth word of a string which matches (NOT case-sensitive) my 'search term'. Illustrated with example code using sashelp dataset. My code : *Create string which will be searched;
%let allowedTeams=montreal Cleveland ATLANTA houston Pittsburgh;
*Test dataset;
data work.baseballTest (drop=allowedT);
set sashelp.baseball(keep=team );
if _n_ < 20;
allowedT='montreal Cleveland ATLANTA houston Pittsburgh';
*Various styles of findw None of which appear to work;
findwRes1 = findw("&allowedTeams",team,' ','ei');
findwRes2= findw(allowedT,team,' ','e i');
findwRes3= findw("montreal Cleveland ATLANTA houston Pittsburgh",team,' ','e i');
findwRes4= findw(upcase("&allowedTeams"),upcase(team),' ','E');
findwRes5= findw("&allowedTeams",team,' ','i');
findwRes6= findw("&allowedTeams",team);
*Indexw locates the string. But extra work is needed to get the ;
*number of the word in the string;
indexwRes= indexw(upcase("&allowedTeams"), upcase(team));
if indexwres > 0 then do;
indexwRes1= countw(substr("&allowedTeams", 1, indexwRes), ' ', 'i');
end;
run; On running this code I attempt several different ways to get the FINDW to work for me (findwRres1-6) . Looking in the resultant dataset none of them do as they are all =0. I am able to use a workaround using indexw and countw (as shown) which does work correctly but is not as slick as the FINDW solution would be. Can anyone suggest what is going wrong with my findw attempts?
... View more
I used function put to convert a variable from num to char and then save the data as csv. However, when I import the saved csv data I found this variable became back to numeric again. I wonder how to keep the variable as char in the csv data?
... View more
Hi guys,
suppose to have the following:
data DB1;
input ID Index_date Code Admission Discharge Status Date;
format Admission Discharge date9.;
cards;
0001 1 49121 11JAN2018 07FEB2018 Died .
0001 1 4660 11JAN2018 07FEB2018 Died .
0001 0 4821 23MAY2021 21JUN2021 Died .
0002 1 4660 01OCT2017 10OCT2017 Died .
0003 1 4659 30MAY2017 7JUN2017 Died .
0003 0 4659 01JAN2018 10JAN2018 Died .
0004 1 V0182 11NOV2021 17NOV2021 Died .
0004 1 V0182 11NOV2021 17NOV2021 Died .
0004 1 4829 11NOV2021 17NOV2021 Died .
;
data DB2;
input ID Index_date Code Admission Discharge Status Date;
format Admission Discharge date9.;
cards;
0001 1 49121 11JAN2018 07FEB2018 Died 22JUN2021
0001 1 4660 11JAN2018 07FEB2018 Died 22JUN2021
0001 0 4821 23MAY2021 21JUN2021 . .
0002 1 4660 01OCT2017 10OCT2017 Died 11OCT2017
0003 1 4659 30MAY2017 07JUN2017 Died 11JAN2018
0003 0 4659 01JAN2018 10JAN2018 . .
0004 1 V0182 11NOV2021 17NOV2021 Died 18NOV2021
0004 1 V0182 11NOV2021 17NOV2021 Died 18NOV2021
0004 1 4829 11NOV2021 17NOV2021 Died 18NOV2021
;
The desired output id DB2.
I would like to assign the death date as the day after the last recorded discharge date for each ID. It could happen that there is only one Admission-Discharge date for a patient like for ID = 002. Doesn't matter. It could also happen that the Admission-Discharge date is repeated equally (es: ID: 004). This happens because of different recorded codes. Doesn't matter. The death date should be the first day after the last (and repeated) discharge date. Patients are sorted by ID and Admission date. Note that there is also an Index_date that indicate the first admission for that patient.
Finally the format of the table DB2 should be changed with respect to DB1. The death date and the word "Died" should be added to the row where Index_date = 1.
Can anyone help me please?
Thank you in advance
... View more
Hi I am new to proc template . 1. I am displaying bar value at the top of bar using barlabel=true. How to display the value at the center of the bar instead of top? 2. Also, how to wrap x axis value. text variable have one value very long 3. what option in proc template i can use to display P value at the top. Thanks in advance
... View more
Hi everyone, I would like to make a table which displays a total of all non-missing values across multiple class row variables, for each level of the column variable. My idea was this code: PROC TABULATE data=have missing; class columnvar rowvar1-rowvar10; table rowvar1-rowvar10 all, columnvar; run; but unfortunately it doesn't work. Instead of displaying the total of all non-missing values across all the row variables in the ALL variable, it just provides a total of the last rowvariable 10. Many thanks in advance, Curt
... View more