Skip to content

Instantly share code, notes, and snippets.

View cjdinger's full-sized avatar

Chris Hemedinger cjdinger

View GitHub Profile
/* Example code to access Pokemon data */
/* Author: Chris Hemedinger */
/* See explanation at: */
/* http://blogs.sas.com/content/sasdummy/build-your-pokemon-library-using-sas */
/* First an example that uses the Pokeapi from SAS */
/* utility macro to put file contents to SAS log */
%macro echoResp(fn=);
data _null_;
infile &fn;
/* Example code publish to Slack channel */
/* Author: Chris Hemedinger */
/* See explanation at: */
/* http://blogs.sas.com/content/sasdummy/slack-channel-with-sas/ */
%macro echoResp(fn=);
data _null_;
infile &fn;
input;
@cjdinger
cjdinger / zip_addfile_example.sas
Created March 4, 2016 20:53
Example of using FILENAME ZIP to create a ZIP file, add to it, and report on the contents
/* Your zip file folder location */
%let projectDir = c:\temp;
/* macro to assign a fileref to a SAS data set in a Base library */
%macro assignFilerefToDataset(_dataset_name);
%local outDsName;
ods output EngineHost=File;
proc contents data=&_dataset_name.;
run;
proc sql noprint;
select cValue1 into: outDsName
@cjdinger
cjdinger / SignsOfUSPresidents_SAS.ipynb
Created November 14, 2016 18:42
Signs of US Presidents, formatted with SAS
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Prism.languages.sas = {
'datalines': {
/* fixed datalines pattern to include datalines4 and possible whitespace before terminating ; */
pattern: /(^|[\r\n])\s*(?:(?:data)?lines|cards|datalines4);[\s\S]+?[\r\n](\s)*;/i,
lookbehind: true,
inside: {
'keyword': {
pattern: /^(\s*)(?:(?:data)?lines|cards|datalines4)/i,
lookbehind: true
},
/* http://prismjs.com/download.html?themes=prism&languages=sas */
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/
/* for Lithium messages */
/* a very specific style override for SAS language in a PRE tag */
#lia-body .lia-content .lia-message-body pre.language-sas,
@cjdinger
cjdinger / zipfiles_list_extract.sas
Created June 9, 2017 13:58
Example of using FILENAME ZIP to list and extract files from ZIP archives
%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 / SASGlobalForumDemo.ipynb
Last active January 8, 2018 12:50
A sample notebook from SAS Global Forum 2016
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cjdinger
cjdinger / rngs-thanos.sas
Last active May 8, 2018 13:37
Which random number generator did Thanos use?
/* 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 / TLaPD_ApiCall.sas
Created September 19, 2014 20:52
SAS program to use the ARRPI translator to Pirate Speak
/*
This SAS program uses the ARRPI translator at:
http://isithackday.com/arrpi.php
To translate whatever English text you supply into
Pirate speak for Talk Like a Pirate Day
*/
%let text = %sysfunc(urlencode('Hello, SAS users are the best'));
filename resp TEMP;
proc http