Skip to content

Instantly share code, notes, and snippets.

Chris Hemedinger cjdinger

Block or report user

Report or block cjdinger

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cjdinger
cjdinger / snackbot_byday.sas
Last active Jul 2, 2018
SnackBot API and time series analysis
View snackbot_byday.sas
/*
Described in the blog post:
The Internet of Snacks: SnackBot data and what it reveals about SAS life
https://blogs.sas.com/content/sasdummy/snackbot-api-timeseries/
by Chris Hemedinger
*/
/* Use these ODS statements in SAS for Windows or SAS Enterprise Guide */
ods _all_ close;
filename results "%sysfunc(getoption(WORK))/snackbot.htm";
ods html5 file=results style=Htmlencore gtitle options(svg_mode="inline");
@cjdinger
cjdinger / rngs-thanos.sas
Last active May 8, 2018
Which random number generator did Thanos use?
View rngs-thanos.sas
/* Which RNG did Thanos use? */
/* https://blogs.sas.com/content/sasdummy/rng-avengers-thanos/ */
/* Using STREAMINIT with the new RNG algorithm argument */
%let algorithm = PCG;
data characters;
call streaminit("&algorithm.",2018);
infile datalines dsd;
retain x 0 y 1;
length Name $ 60 spared 8 x 8 y 8;
@cjdinger
cjdinger / SASGlobalForumDemo.ipynb
Last active Jan 8, 2018
A sample notebook from SAS Global Forum 2016
View SASGlobalForumDemo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cjdinger
cjdinger / zipfiles_list_details.sas
Last active Dec 20, 2017
SAS macros that use FILENAME ZIP and FINFO to list the contents of ZIP files and all of the file details (size, compressed size, full path, etc). See full explanation at http://blogs.sas.com/content/sasdummy/filename-zip-details/
View zipfiles_list_details.sas
/* Produce a list of ZIP files and their entries from a single folder */
%macro listzipcontents (
targdir= /* a system folder that contains ZIP files */,
outlist= /* output data set for list of files and members */);
filename targdir "&targdir";
/* Gather all ZIP files in a given folder */
/* Searches just one folder, not subfolders */
/* for a fancier example see */
/* http://support.sas.com/kb/45/805.html (Full Code tab) */
@cjdinger
cjdinger / zipfiles_list_extract.sas
Created Jun 9, 2017
Example of using FILENAME ZIP to list and extract files from ZIP archives
View zipfiles_list_extract.sas
%macro listzipcontents (targdir=, outlist=);
filename targdir "&targdir";
/* Gather all ZIP files in a given folder */
/* Searches just one folder, not subfolders */
/* for a fancier example see */
/* http://support.sas.com/kb/45/805.html (Full Code tab) */
data _zipfiles;
length fid 8;
fid=dopen('targdir');
@cjdinger
cjdinger / import_renameV7.sas
Last active Sep 13, 2018
Example to read CSV file from the web, import to SAS with nonstandard var names, then rename/relabel to conform with standard SAS variable name rules .
View import_renameV7.sas
/* Example to read CSV file from the web */
/* Import to SAS with nonstandard var names */
/* Then rename/relabel to conform with standard */
/* SAS variable name rules */
/* Fetch the file from the web site */
filename probly temp;
proc http
url="https://raw.githubusercontent.com/zonination/perceptions/master/probly.csv"
method="GET"
@cjdinger
cjdinger / googleanalytics_example.sas
Last active May 13, 2018
Template SAS program to fetch data from Google Analytics. Requires that you set up your own account and API project in Google developer console. Uses PROC HTTP and JSON libname engine. See blog post here: http://blogs.sas.com/content/sasdummy/using-sas-to-access-google-analytics-apis/.
View googleanalytics_example.sas
/* Copyright 2017 SAS Institute */
/* Author: Chris Hemedinger */
/* http://blogs.sas.com/content/sasdummy/using-sas-to-access-google-analytics-apis/ */
/* PREREQUISITES */
/* Use the Google Developer console to define a project */
/* and application, and generate a client-id and client-secret token */
/* Of course, you'll need access to a Google Analytics account with at */
/* least one view profile that allows access to metrics and dimensions. */
/* STEP 1. Need to perform just once in a BROWSER. */
@cjdinger
cjdinger / github_acctstats.sas
Created Jan 4, 2017
Using SAS to report on GitHub repos for an organization or user account
View github_acctstats.sas
/* Fetch the repositories and stats from an */
/* organization's account on GitHub */
/* Requires SAS 9.4 Maint 4 */
/* by Chris Hemedinger */
/* Copyright 2017 SAS Institute Inc. */
/* Change this value to the account you want to report on */
/* Some fun accounts: netflix, spotify, apache */
%let account=sassoftware;
%let acct_type=orgs;
@cjdinger
cjdinger / jsonlib_communities.sas
Created Dec 2, 2016
Example of using JSON libname engine
View jsonlib_communities.sas
/****************************************/
/* Example of using JSON libname engine */
/* for discovery, then with a JSON map */
/* Copyright 2016 SAS Institute */
/* written by Chris Hemedinger */
/* http://blogs.sas.com/sasdummy */
/****************************************/
/* split URL for readability */
%let url1=http://communities.sas.com/kntur85557/restapi/vc/categories/id/bi/topics/recent;
@cjdinger
cjdinger / SignsOfUSPresidents_SAS.ipynb
Created Nov 14, 2016
Signs of US Presidents, formatted with SAS
View SignsOfUSPresidents_SAS.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.