Skip to content

Instantly share code, notes, and snippets.

View josephlei's full-sized avatar

Joseph josephlei

  • Google Cloud
  • Mountain View, CA
View GitHub Profile
@josephlei
josephlei / phone_clean.bas
Last active January 23, 2023 17:33
VBA macro to clean and format phone numbers
Sub PHONECLEAN()
Dim rngActiveRange As Excel.Range
Set rngActiveRange = Selection
rngActiveRange.Select
' REMOVE ALL NON-NUMERICAL CHARACTERS
Selection.Replace What:=".", Replacement:=""
Selection.Replace What:="-", Replacement:=""
Selection.Replace What:=" ", Replacement:=""
Selection.Replace What:="(", Replacement:=""
@josephlei
josephlei / comma.bas
Last active August 29, 2015 14:17
VBA macro to format numerics into #,### which CAN be left aligned
Sub COMMA()
Selection.NumberFormat = "#,###;[RED]-#,###;0"
Selection.HorizontalAlignment = xlLeft
End Sub
@josephlei
josephlei / SAS_PARSE_DISCRETE_VARS.SAS
Created April 16, 2015 18:42
SAS Macro definition for splitting one large file into smaller ones based on a key column containing discrete values
OPTIONS NOMPRINT MCOMPILENOTE=ALL NOSYMBOLGEN NOMLOGIC;
DATA SASUSER.COUNTY_SAWS_REF;
LENGTH COUNTY $13 SAWS $3;
INFILE DATALINES DSD DLM=",";
INPUT COUNTY $ SAWS $;
DATALINES;
ALAMEDA,CW
ALPINE,CIV
AMADOR,CIV
@josephlei
josephlei / UPCASE_ALL.SAS
Created October 19, 2015 16:19
SAS MACRO DEFINITION TO UPCASE ALL CHARACTER VARIABLES IN A SPECIFIED DATA SET
*MODIFY THESE GLOBAL OPTIONS AS NEEDED FOR DEBUGGING;
OPTIONS NOMLOGIC NOSYMBOLGEN NOMPRINT;
/***************************************************
CALL/INVOKE MACRO AFTER COMPILATION AS SHOWN HERE;
SYNTAX: %UPCASEALL(LIBRARY_REFERENCE, DATASET_NAME);
EXAMPLE: %UPCASEALL(WORK,_PRODSAVAIL);
***************************************************/
@josephlei
josephlei / LessonOne.R
Created July 20, 2016 01:32 — forked from bryangoodrich/LessonOne.R
Adventures in R Training Code
#########################################
# Lesson 1 - R Basics
#
# Learning Objectives
# 1. R Data Types
# 2. Indexing
# 3. Boolean Logic and Filtering
# 4. Importing/Exporting
# 5. The R Environment
#########################################