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.
Would u like to help me to categorize market values into three groups labeled as small, mid, and big? FIRMS ARE ASSIGNED TO A SIZE QUARTILE GROUP BASED ON THEIR PREVIOUS MONTH’S MARKET VALUE OF EQUITY THE 0~<25% ARE GROUP BY SMALL SIZE, THE 25%~<50% ARE GROUP BY MEDIUM SIZE, THE 50%~100% ARE GROUP BY BIG SIZE. PROC SORT DATA BY DATE PERMNO MARKET VALUE(SMALL TO BIG), AND GIVE EACH DATE PERMNO MARKET VALUE. DATA SORTED;
SET SORTED;
BY DATE PERMNO;
IF LAST.PERMNO THEN DO;
CALL STREAMINIT(123);
RANK = RANKTIE(LAST_MONTH_MV, 'DESCENDING');
PCTILE = RANK / (LAST.PERMNO + 1);
IF PCTILE < 0.25 THEN SIZE_GROUP = 'SMALL';
ELSE IF PCTILE < 0.50 THEN SIZE_GROUP = 'MEDIUM';
ELSE SIZE_GROUP = 'BIG';
END;
RUN; ERROR 68-185: The function RANKTIE is unknown, or cannot be accessed.
... 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
data have;
input ID $ a_cnt $ b_cnt $ month $ L_1 $ L_2 $ Dum;
datalines;
1 2 1 jan A1 b1 0
2 0 0 feb a2 b2 0
3 1 0 mar a1 b2 0
4 0 1 jan a2 b3 0
;
proc print data=have;
proc tabulate data=have;
class l_1 l_2 month;
var a_cnt;
table l_1*l_2, (month all='Total')*(a_cnt='')*(sum='');
run; i am trying to use tabulate to produce a table like below... but i am not able to acheive the same. any help much appreciated.
... View more
Proc export giving additional quotes to the quoted char values.and if u use data step for that it is giving a space or . To numeric values which is not required . Needs to change nothing.now it is , , but want ,, no space no .for missing numeric value.
... View more
Wondering about methods to hide a row in PROC TABULATE.
Suppose I have a simple table with DATE in rows, PASS in column and have a total row. So daily data for April like:
data have ;
do date='01Apr2024'd to '30Apr2024'd ;
do id=1 to 5 ;
pass=ranuni(9)<.3 ;
output ;
end ;
end ;
format date date9. ;
run ;
proc tabulate data=have;
class date pass ;
tables (date all),pass ;
run ;
I want to make that table, but show only the rows for Apr 24 -Apr 30, and the ALL row. But I want the ALL row to reflect all 30 days, even though the table only shows rows for 7 days.
In my mind, I want the table as above, but just hide the rows for Apr 1 - Apr 23.
My first thought is to extend my data to have data as is for April 24-30, and then output all the rows again with date set to some arbitrary value that I can use to make an "ALL" row. So something like:
data want ;
set have ;
if date>='24Apr2024'd then output ;
date='09Sep2099'd ;
output ;
run ;
proc format ;
value datef
'09Sep2099'd='01Apr2024 - 30Apr2024'
other=[date9.]
;
run ;
proc tabulate data=want;
class date pass ;
tables date,pass ;
format date datef. ;
run ;
That works and gives me the desired output:
----------------------------------------------------------
| | pass |
| |-------------------------|
| | 0 | 1 |
| |------------+------------|
| | N | N |
|------------------------------+------------+------------|
|date | | |
|------------------------------| | |
|24APR2024 | 3.00| 2.00|
|------------------------------+------------+------------|
|25APR2024 | 3.00| 2.00|
|------------------------------+------------+------------|
|26APR2024 | 4.00| 1.00|
|------------------------------+------------+------------|
|27APR2024 | 3.00| 2.00|
|------------------------------+------------+------------|
|28APR2024 | 5.00| .|
|------------------------------+------------+------------|
|29APR2024 | 4.00| 1.00|
|------------------------------+------------+------------|
|30APR2024 | 4.00| 1.00|
|------------------------------+------------+------------|
|01Apr2024 - 30Apr2024 | 113.00| 37.00|
----------------------------------------------------------
But I'm curious about other options. It almost feels like I could do this with a MULTILABEL format and a CLASSDATA dataset, but in the end I don't think that will work.
I will be using ODS for the output (probably ODS POWERPOINT). So I guess I could try setting a STYLE attribute like ROWHEIGHT=0 for some rows (using CLASSLEV), and see if TABULATE will let me 'hide' a row that way.
... View more