Skip to content

Instantly share code, notes, and snippets.

View rpardee's full-sized avatar

Roy Pardee rpardee

View GitHub Profile
@rpardee
rpardee / bewildering_input.sas
Created September 18, 2012 13:45
Bewildering SAS input
data gnu ;
input
studyid $char6.
event_datetime $char26.
event_name $char50.
;
infile datalines
dsd
delimiter = '09'x
firstobs = 2
@rpardee
rpardee / sgpanelbug.sas
Created October 12, 2012 18:29
SGPanel bug?
data gnu ;
input
@1 var_name $char20.
@23 value $char1.
@27 enr_end date9.
@39 site $char1.
@43 pct
;
format
enr_end mmddyy10.
@rpardee
rpardee / gist:7586054
Created November 21, 2013 17:35
regex solution to a sas-l problem.
data have;
retain prx ;
input path : $800.;
if _n_ = 1 then do ;
prx = prxparse("(Sect1.2.3b|Sect1.1.a|Sect2.3.b|Sect3.3.2c)") ;
end ;
flg = (prxmatch(prx, path) > 0) ;
if flg then do ;
call prxsubstr(prx, path, pos, len) ;
excerpt = substr(path, pos, len) ;
DataBaseName TableName Space_Utilised_KB Avg_Space_Per_Amp_KB Max_Space_Amp_KB SKEWFACTOR
1 SB_GHRI c14NOV2013_cod_no_state 1,795.50 112.22 117.5 4.49
2 SB_GHRI c14NOV2013_death_no_state 3,614.00 225.88 231.5 2.43
3 SB_GHRI c14NOV2013_death 6,927.50 432.97 438 1.15
4 SB_GHRI c14NOV2013_cod 10,232.50 639.53 647 1.15
5 SB_GHRI c14NOV2013_specfile 13,242.50 827.66 836.5 1.06
6 SB_GHRI c20NOV2013_person_languages 17,970.00 1,123.13 1,134.50 1
7 SB_GHRI c27FEB2013_everndc 23,660.50 1,478.78 1,507.50 1.91
8 SB_GHRI c05NOV2013_tumor_ghc_cases 26,137.00 1,633.56 1,700.50 3.94
9 SB_GHRI c20NOV2013_demog 173,335.00 10,833.44 10,860.00 0.24
@rpardee
rpardee / gist:db3fbeecad8bae038008
Created May 21, 2014 21:13
SAS GTL for 'butterfly' plot
proc template ;
define statgraph psa_butterfly ;
begingraph ;
layout lattice _id='lattice' / columndatarange = data
columngutter = 0
rowdatarange = data
rowgutter = 10
/* columnweights = (0.62 0.38) */
columns = 2 ;
layout overlay _id='overlay' / yaxisopts = (gridattrs=(color=CXE8E6E8 pattern=SOLID thickness=1 )
@rpardee
rpardee / %limited_freq
Created May 27, 2014 16:13
SAS macro to produce a FREQ of the top-N most frequently ocurring values of a variable.
%macro limited_freq(inset = s.car_adm_f, var = , rowlim = 10) ;
proc sql outobs = &rowlim nowarn ;
create table topn as
select &var, count(*) as frq
from &inset
group by &var
order by 2 desc
;
quit ;
/*********************************************
* Roy Pardee
* Group Health Research Institute
* (206) 287-2078
* pardee.r@ghc.org
*
* C:\Users/pardre1/Desktop/deleteme.sas
*
*
*********************************************/
@rpardee
rpardee / gist:ed4cfc85f23081fd1a44
Created February 4, 2015 21:15
sas -> teradata temp table: why won't teradata do this join?
* Write db commands to the log. ;
options
fullstimer
sastrace = ',,,d'
sastraceloc = saslog
;
%let my_server = EDW_PROD1 ;
%let my_schema = SB_GHRI ;
@rpardee
rpardee / gist:a8742c39734f205c62c6
Created February 17, 2015 18:03
Unroll LOINC & CPT lists to create a search_keys table for finding lab test indicators
require "win32ole"
=begin
Parsing strategy for unrolling the lists.
lists are either CPTs or LOINCs
CPTs are \d{5}.
Loincs are \d{4,5}-\d
Particular, problematic list is:
proc format ;
value $sx
"F" = "Girls"
"M" = "Boys"
;
value ag
low - 12 = '12 and under'
13 - high = '13 and up'
;
quit ;