Skip to content

Instantly share code, notes, and snippets.

View cjdinger's full-sized avatar

Chris Hemedinger cjdinger

View GitHub Profile
@cjdinger
cjdinger / jsonlib_communities.sas
Created December 2, 2016 15:53
Example of using JSON libname engine
/****************************************/
/* 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 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.
/* 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,
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
},
/* 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;
/* 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;
@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 / 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
@cjdinger
cjdinger / SasMetadataGetColumns.ps1
Created February 21, 2013 14:57
Example of using PowerShell to connect to a SAS Metadata Server and retrieve a list of registered libraries, tables and columns. Like PROC METADATA, this example can be adapted to retrieve many types of metadata-related objects and attributes.
# SasMetadataGetColumns.ps1
# Example usage:
# For table grid display, use:
# .\SasMetadataGetColumns.ps1 | Out-Gridview
# For export to CSV
# .\SasMetadataGetColumns.ps1 | Export-Csv -Path "c:\output\cols.csv" -NoTypeInformation
# -------------------------------------------------------------------
# create the Integration Technologies objects
$objFactory = New-Object -ComObject SASObjectManager.ObjectFactoryMulti2
$objServerDef = New-Object -ComObject SASObjectManager.ServerDef
@cjdinger
cjdinger / SasWorkspaceDownloadFile.ps1
Created February 20, 2013 22:05
Example of how to use SAS Workspace APIs to download a file from a remote SAS session. Uses SAS LanguageService and FileService APIs, part of IOM.
# Example of how to use PowerShell to script the
# SAS Integration Technologies client
# You can connect to a remote SAS Workspace
# and run a program, retrieve the SAS log and download a file
# To use: change this script to reference your SAS Workspace
# node name, port (if different), and user credentials
# create the Integration Technologies objects
$objFactory = New-Object -ComObject SASObjectManager.ObjectFactoryMulti2