This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*--- setup unit test; | |
%let source_dir = /user/SASTest/source; | |
%let target_dir = /user/SASTest/target; | |
x "mkdir -p &source_dir."; | |
x "mkdir -p &target_dir."; | |
libname srclib "&source_dir."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%macro scd2(src_table_lib,src_table_name,unique_record_key,tgt_table_lib,tgt_table_name); | |
/* | |
src_table_lib: sas libname | |
src_table_name: sas table name | |
unique_record_key: unique key, must be a single column not a combination | |
tgt_table_lib: sas libname | |
tgt_table_name: sas table name | |
*/ | |
%put &=src_table_lib.; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def weightedMovingAverage(period, data): | |
# --- Weighted Moving Average | |
# data: array, time series data e.g. daily close prices | |
# period: integer, number of periods from time series array to include in calculation | |
import numpy as np | |
# --- get first non nan index | |
for i in range(len(data)): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function fileNamePath() As String | |
'--- fileNamePath() | |
' in: n/a | |
' out: string, path and name of selected file | |
' desc: opens an explorer window so the user can select a file. No file type filters are applied. | |
Dim fd As Office.FileDialog | |
Set fd = Application.FileDialog(msoFileDialogFilePicker) | |
With fd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* setup test data*/ | |
data test_data; | |
input raw_string & $50.; | |
datalines; | |
001-5845-69995 | |
t3sting_%$£ h^%)k | |
this one should be 100 percent fine | |
B*FHE`£lDO | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clearRAM(print_usage=False): | |
import os | |
from hurry.filesize import size | |
import psutil | |
import gc | |
#--- clear ram | |
gc.collect() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gc | |
gc.collect() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*--- define scheduler macro; | |
%macro egScheduler; | |
*--- SAS Enterprise Guide Scheduler; | |
* &today: date when the scheduler was kicked off; | |
* &rundays: max days scheduler will run continuously; | |
* ¬ificationdays: send notification when shceudler reaches this number of rundays; | |
* &logdir: directory where log fiels are to be saved; | |
* &job_name: full path to code including name + extension; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
table_schema | |
,table_name | |
,pg_size_pretty(total_bytes) AS total_size | |
,pg_size_pretty(index_bytes) AS index_size | |
,pg_size_pretty(toast_bytes) AS toast_size | |
,pg_size_pretty(table_bytes) AS table_size | |
FROM ( | |
SELECT | |
table_schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sharpeRatio(returns, periods, rf=0): | |
# --- Annualised Sharpe Ratio | |
# returns: array, percentage change values in decimals | |
# periods: int, annual periods in returns (e.g. days = 252, months = 12) | |
# rf: decimal, Risk Free Rate generally zero but can be specified as a decimal | |
import numpy as np | |
sr = np.sqrt(periods) * ((np.nanmean(returns) - rf) / np.nanstd(returns)) |
NewerOlder