Thoughts of a Crime Show Junkie: Inadmissible Evidence
Recent Library Articles
Recently in the SAS Community Library: SAS' @RhondaWilliams reveals how SAS Law Enforcement Intelligence helps law enforcement agencies expedite detailed data entry using the Evidence Creation feature.
I need to combine same clinic names if the corresponding prior_span =1.
For example, if Clinic_name1 and Clinic_name2 where both Clinic A and Prior_span1 and prior_span2 both =1 then Clinic would = A.
Clinic_name_1 corresponds with Prior_span1
Clinic_name_2 corresponds with Prior_span2
Clinic_name_3 corresponds with Prior_span3
Below is my sample data.
Thanks!
Data Have;
input
ID$ Clinic_Name_1$ Clinic_Name_2$ Clinic_Name_3$ Prior_Span1$ Prior_Span2$ Prior_Span3$ Cost service$ ;
datalines;
1 B A . 0 0 0 168 A
2 A A . 1 0 0 46 B
2 A A . 0 1 0 99 C
3 B . . 0 0 0 24 D
4 D . . 0 0 0 54 A
5 B D F 0 1 0 405 B
7 A . . 1 0 0 90 F
8 E E A 0 0 1 87 J
9 F . . 0 0 0 0 G
10 C C C 0 0 0 40 C
10 C C C 0 0 1 374 B
10 C C C 0 1 1 60 A
;
run;
***Summary table-clinic var not created yet****;
proc sql;
create table want as
select 1 as ID1,'service' as a length=40,Clinic,
1 as ID2,put(service, $40.) as b length=40,
1 as ID3,(select count(distinct ID) from have where Clinic=a.Clinic and service=a.service and cost>0 ) as c format=comma20.,
1 as ID4,calculated c/(select count(distinct ID) from have where Clinic=a.Clinic and cost>0 ) as d format=percent8.1,
1 as ID5,sum(cost) as e format=dollar20.,
1 as ID6,sum(cost)/(select sum(cost) from have where Clinic=a.Clinic) as f format=percent8.1
from have as a
group by Clinic,service
union all
select 7 as id1,'09'x as a,Clinic,
7 as id2,'Total Clients' as b,
7 as id3,count(distinct ID) as f,
7 as id4,.,
7 as id5,.,
7 as id7,.
from have
where service ne 'j' and cost>0
group by Clinic
union all
select 7 as id1,'09'x as a,Clinic,
7 as id2,' Total Cost' as f,
7 as id3,. as c,
7 as id4,.,
7 as id5,sum(cost),
7 as id7,.
from have
where service ne 'j' and cost>0
group by Clinic
;quit;
options missing=' ';
proc report data=want nowd;
column id1 a b Clinic,(c d e f);
define id1/group noprint;
define a/group noprint ' ';
define b/group ' ';
define c/analysis 'Clients';
define d/analysis '% of Clients';
define e/analysis 'Cost';
define f/analysis '% of Cost';
define Clinic/across '';
compute before a/style={just=l color=black};
if id1=1 then len=0;
else len=10;
x=' ';
line x $varying10. len;
line a $40.;
endcomp;
run;
... View more
Hi,
I have a character birthdate variable and I am trying to convert it to numeric but getting errors in my input function. Thanks
Here is my code:
data want; set have; birthday_num= input(strip(birthdate), anydtdte.); format birthday_num mmddyy10.; run;
... View more
DATA ALT;
SET RCA.CLOSING_STATUS_TEST;
ARRAY COLS[*] _CHARACTER_;
ARRAY COLS_[*] _CHARACTER_;
DO I = 1 TO DIM(COLS);
IF MOD(I, 2) = 1 THEN
COLS_[(I+1)/2] = COLS[I];
END;
DROP I;
RUN;
Hi, I have been trying to select the alternate columns. If I am using this code then my third column's data shifts to second column and second's values are disappearing. I want to select alternate columns from my data set and my column names are in following: LOAN_NO, PRODUCT, FINAL_STATUS_05MAY24,DUE_N_TAG_05MAY24, FINAL_STATUS_06MAY24,DUE_N_TAG_06MAY24, FINAL_STATUS_07MAY24,DUE_N_TAG_07MAY24,... and so on. I want to create a table selecting columns:-
LOAN_NO, FINAL_STATUS_05MAY24, FINAL_STATUS_06MAY24, FINAL_STATUS_07MAY24... and so on. If there is any alternate approach for making the selection, please advise me or please help with the given array code.
... View more
Hello everyone, I am trying to select alternate columns from my dataset, starting from column number 1 and including every nth alternate column after that. For example, I want to select columns 1, 3, 5, 7, and so on up to column n. Is there a way to make this selection without having to manually specify the column names? Here are my column headers: FINAL_STATUS_01MAY24, FINAL_STATUS_02MAY24, and so on...
I would appreciate any help or advice. Thank you!
... View more
I would like to delete the folder folderToDelete, which contains subfolders and those folders might contain subfolders, and so on. I do not have permission to do the x command. I have the following code (after looking at the following post Delete folder (directory) and all files in it😞 %macro delete_folder(folderToDelete);
data work.FilesToDelete;
length Name $ 100;
keep Name;
rc = filename("folder", "&folderToDelete.");
dirId = dopen("folder");
do i = 1 to dnum(dirID);
Name = dread(dirId, i);
output;
end;
rc = dclose(dirId);
run;
data _null_;
set work.FilesToDelete end=lastDeleted;
put "Deleting " Name;
rc = filename("delfile", cats("&folderToDelete./", Name));
rc = fdelete("delfile");
put "del file " rc=;
rc = filename("delfile");
if lastDeleted then do;
put "Deleting the folder '&folderToDelete.'";
rc = filename("folder", "&folderToDelete.");
rc = fdelete("folder");
put "del folder " rc=;
rc = filename("folder");
end;
run;
%mend; However, since my folder contains subfolders, only the tables are delete and not the subfolders, resulting in the main folder not being deleted. In that sense, what I would like was to apply a function recursively to delete every file inside any subfolder (or any other suggestion you might have). As an example, if my folder has the following structure: > folder > subfolder_1 > T_1_1.sas7bdat > T_1_2.sas7bdat > T_1_3.sas7bdat > subsubfolder_1 > T_1_1_1.sas7bdat > subfolder_2 > T_2_1.sas7bdat > T_1.sas7bdat > T_2.sas7bdat > T_3.sas7bdat > T_4.sas7bdat after running the first data step, which reads the folder, I get Name subfolder_1 subfolder_2 T_1.sas7bdat T_2.sas7bdat T_3.sas7bdat T_4.sas7bdat and then in the second data step, only the tables are deleted. However, I would like to delete the entirety of the folder. Can someone help?
... View more