Technology Tales

Notes drawn from experiences in consumer and enterprise technology

09:40, 24th October 2022

SAS NWKDOM Function

The NWKDOM function in SAS calculates the date of the nth occurrence of a specified weekday within a given month and year, returning a numeric SAS date value. It accepts parameters for the week number (1–5), weekday (1–7, with Sunday as 1), month (1–12) and a four-digit year and is particularly useful for determining dates of events not covered by standard holiday functions. For example, it can identify the third Monday in May 2012 or the last Monday in May 2012, with outputs formatted using SAS date conventions.

09:39, 24th October 2022

The JSON LIBNAME Engine: Real-World Applications Using Open APIs

The JSON LIBNAME engine in SAS offers a straightforward way to access and extract data from JSON files, eliminating the need for complex parsing code. This feature is particularly useful when dealing with APIs that return data in JSON format, such as those from Google Maps or the US Census Bureau. By using the engine, users can directly import structured data into SAS without manually interpreting the JSON structure.

For instance, reverse geocoding coordinates through the Google Maps API becomes a simple process, with the engine automatically generating datasets containing relevant information like addresses and geographical details. Similarly, the US Census API allows users to explore datasets by first reading descriptor files, which list available data sources.

A macro can then dynamically fetch and process example JSON files from these sources, streamlining the workflow significantly. This capability not only saves time but also ensures that new data added to APIs is easily integrated into SAS analyses.

The engine's reliability and ease of use make it a valuable tool for SAS programmers, enabling them to leverage a wide range of JSON-based data sources efficiently. As more services adopt JSON for data exchange, the JSON LIBNAME engine positions SAS users to adapt quickly and effectively to new opportunities.

20:49, 23rd October 2022

WorldTimeAPI is a straightforward web service that returns the current local time for a given timezone in either plain or JSON format. Alongside the current date/time, the service provides additional details such as the UTC offset, day of the week, day of the year, week number, Unix timestamp and daylight saving time information, including whether DST is currently active and the dates on which it begins and ends. The service does not use cookies and is free to query via a simple API call.

09:37, 21st October 2022

Distinguishing SAS PROC MEANS, SUMMARY, TABULATE

SAS offers three related but distinct procedures for generating descriptive statistics. PROC MEANS computes statistics across all observations or within groups, estimates quantiles, calculates confidence limits and identifies extreme values, with results displayed in the output window. PROC SUMMARY functions identically but writes its results to an output dataset instead. PROC TABULATE builds on both by presenting descriptive statistics in a tabular format, offering greater flexibility in classifying variables, establishing hierarchical relationships and applying labels and formatting, with output available in either the window or a dataset.

In SAS Enterprise Guide, PROC MEANS is accessible via the Describe menu under Summary Statistics, while PROC TABULATE is found under Summary Tables, and PROC SUMMARY requires manual coding. In SAS Studio, only PROC MEANS is available through the Statistics menu, with the other two also requiring code. On SAS Viya, all three procedures use CAS actions when processing CAS tables. While the three procedures are broadly similar in the statistics they produce, PROC TABULATE is generally considered the most versatile due to the greater degree of control it affords over output.

09:35, 21st October 2022

Getting Started with Python Integration to SAS Viya

Peter Styliadis, a Technical Training Consultant at SAS, has compiled an index of articles covering Python integration with SAS Viya, aimed at helping developers and analysts get started with using Python alongside the massively parallel processing CAS engine. The series walks through a broad range of practical topics, beginning with establishing a connection to CAS and progressing through working with CAS actions, loading and exploring data, performing descriptive statistics, filtering and transforming tables, executing SQL and handling missing values, through to more advanced tasks such as creating user-defined functions and connecting to Snowflake. A number of additional learning resources are also signposted, including webinars, a predictive modelling series and guidance on creating Microsoft Excel reports using SAS, Python and SQL together.

20:41, 14th October 2022

Quarto

Pandoc

Quarto is an open-source platform designed for creating dynamic, reproducible content using programming languages such as Python, R and Julia, enabling users to generate articles, presentations, dashboards and books in formats like HTML, PDF and EPUB. It supports authoring through Markdown with enhanced features for equations, citations and layouts and integrates with tools for publishing to platforms like Posit Connect. Pandoc, a complementary document converter, facilitates the transformation of content between numerous markup and document formats, including Markdown, HTML, LaTeX and Word, while offering customisable citation systems and support for advanced formatting options.

09:25, 14th October 2022

LEAVE and CONTINUE: Two ways to control the flow in a SAS DO loop

The SAS DATA step includes LEAVE and CONTINUE statements that function similarly to break and continue in other programming languages, allowing control over loop execution. LEAVE exits a loop immediately when a condition is met, as demonstrated in a simulation where a coin is tossed until "heads" appears, while CONTINUE skips remaining statements in a loop iteration, useful for scenarios like limiting attempts in a trial.

Alternatives such as DO-UNTIL loops can achieve similar outcomes with clearer exit conditions. The author prefers structured approaches to jump statements, though LEAVE may simplify certain logic. Other SAS languages, like SAS/IML, support these statements with version-specific updates, while GOTO offers another method for control flow, though it is generally avoided for readability. The discussion highlights considerations in balancing simplicity and structured programming practices when managing loop operations.

11:57, 12th October 2022

How to examine the status of ODS destinations in SAS

A SAS programmer may encounter issues where tables and graphs do not display due to the ODS SELECT list being set to restrict output or all ODS destinations being closed, which can occur through programmatic commands. To resolve this, restarting the SAS session resets ODS settings, but if the problem persists, examining the SELECT list and open destinations is necessary.

Using the ODS SELECT ALL statement ensures all output is visible, while procedures like PROC PRINT on the SASHELP.VDEST data view reveal active ODS destinations. Checking the SAS log for notes about closed destinations or restricted SELECT lists helps identify the cause, and adjusting these settings through ODS commands or interface preferences can restore proper output display. Understanding these steps allows users to troubleshoot and manage ODS configurations effectively.

14:04, 3rd October 2022

SASPy Configuration with SAS Analytics Pro Cloud Native

SAS Analytics Pro Cloud Native enables SAS to run within a containerised Docker environment, opening up possibilities for continuous integration and deployment pipelines, as well as integration with other applications. A widely used Python package called SASPy allows data scientists and developers to interact with SAS procedures and data steps from within Python workflows, and one of its connection methods relies on STDIO over SSH. To enable this, the SAS Analytics Pro container must be configured to accept SSH connections, which involves creating the necessary configuration files, adding Linux system capabilities, exposing and mapping the appropriate network port and establishing a passwordless SSH key pair on the host machine. Once SSH access is confirmed through command-line testing, SASPy can be configured via a personal configuration file that specifies the connection details including the path to SAS, the host address, port, user credentials and additional parameters to handle host key checking and file transfer behaviour specific to Docker Desktop on Windows. With the configuration in place and a successful test session returning the expected log output, SASPy is fully operational against the containerised SAS environment.

14:03, 3rd October 2022

SASPy is a Python module that enables interaction with SAS systems through APIs, allowing users to initiate SAS sessions, execute analytics and transfer data between SAS datasets and Pandas dataframes. It supports multiple connection methods, including local and remote SAS sessions, and facilitates the use of Python methods such as describe() and head() for data manipulation. Additional features encompass machine learning, econometrics and quality control implemented via Python classes.

The module requires Python 3.4 or higher, SAS 9.4 or later and Java 7 or higher for specific connection types, and it is compatible with various SAS platforms. Documentation includes installation instructions, configuration details, troubleshooting guidance and examples to aid in implementation.

  • The content, images, and materials on this website are protected by copyright law and may not be reproduced, distributed, transmitted, displayed, or published in any form without the prior written permission of the copyright holder. All trademarks, logos, and brand names mentioned on this website are the property of their respective owners. Unauthorised use or duplication of these materials may violate copyright, trademark and other applicable laws, and could result in criminal or civil penalties.

  • All comments on this website are moderated and should contribute meaningfully to the discussion. We welcome diverse viewpoints expressed respectfully, but reserve the right to remove any comments containing hate speech, profanity, personal attacks, spam, promotional content or other inappropriate material without notice. Please note that comment moderation may take up to 24 hours, and that repeatedly violating these guidelines may result in being banned from future participation.

  • By submitting a comment, you grant us the right to publish and edit it as needed, whilst retaining your ownership of the content. Your email address will never be published or shared, though it is required for moderation purposes.