Technology Tales

Notes drawn from experiences in consumer and enterprise technology

17:02, 12th May 2021

SASCrunch

SASCrunch.com offers an online SAS programming training programme aimed at absolute beginners, with the goal of helping learners develop proficiency in SAS within 30 days. The platform takes a coding-oriented approach, encouraging users to learn through practice via more than 150 interactive tutorials, coding exercises and practical projects covering data reading, cleaning, manipulation, analysis and presentation. Training is delivered in an interactive format that allows learners to write and execute code alongside the course material on the same screen. The platform also offers dedicated preparation courses for the SAS Certified Specialist Exam, which now requires candidates to write and execute code during the examination itself, and includes over 300 practice exercises to support that preparation. Students at Duke University can access the base certification training programme at no cost.

15:25, 12th May 2021

Usage Note 19247: SAS Work library startup errors and how to change the WORK library for temporary files to another drive on a Microsoft Windows operating system

On Microsoft Windows, the SAS Work library stores temporary files used during a SAS session and defaults to the system's TEMP directory. Start-up errors such as "ERROR: Invalid physical name for library WORK", "ERROR: Insufficient authorisation to access WORK library" and "ERROR: Library WORK does not exist" typically indicate that the specified directory path is missing or that the user account lacks sufficient permissions to access it.

The location of the WORK library must be configured before a SAS session begins, as it cannot be reassigned once a session is active. To change it, the sasv9.cfg file for the relevant SAS version must be edited using Notepad, run as administrator, by modifying the -WORK option to point to a new directory path to which the user has full control permissions. Alternatively, the -WORK option can be added directly to the SAS application shortcut's target command.

On machines shared by multiple user accounts, incorporating the Windows environment variable !USERNAME into the directory path ensures that each user account maintains a separate Work library. In either case, a restart of the SAS session is required for the new location to take effect, and assistance from an IT department may be necessary if permissions issues arise during the process.

15:24, 12th May 2021

How do I locate the SAS temporary work directory?

There are at least two ways to locate the temporary work directory that SAS uses. In a Windows environment, this can be done by right-clicking the work icon in SAS and selecting "Property". Alternatively, SAS syntax can be used, either through the options procedure or the %sysfunc(getoption(work)) function, the latter of which is particularly useful when working outside of Windows or when the directory path needs to be passed to a SAS programme. It is also possible to store the directory path in a macro variable for future use within a programme, using the %let command in combination with the %sysfunc function.

11:17, 12th May 2021

How to download and convert CSV files for use in SAS

Chris Hemedinger of SAS demonstrates how to download a CSV file from GitHub and prepare it for use in SAS, using a four-step process. First, PROC HTTP is used to fetch the raw file from GitHub, as it is considered more robust and efficient than alternative methods. Next, PROC IMPORT brings the data into SAS with the VALIDVARNAME=ANY option enabled, allowing the original column names containing spaces or special characters to be retained temporarily. The third step uses PROC SQL with a SELECT INTO clause to dynamically generate RENAME and LABEL statements, converting the original column names into valid SAS variable names by stripping spaces and non-alphanumeric characters, while preserving the originals as descriptive labels. Finally, PROC DATASETS applies these generated statements to update the variable names and labels without rewriting the entire dataset, after which the VALIDVARNAME option is reset to its standard setting. The approach is particularly useful when working with externally sourced data whose column naming conventions do not conform to SAS programming rules.

11:16, 12th May 2021

R to SAS

Robert Allison, a data visualisation specialist at SAS, has published a series of blog posts exploring the conversion of graphs created in R into their SAS equivalents. The series covers a range of chart and map types, including pie charts, bar charts and maps generated from shapefiles, with each post taking a detailed look at how customised R visualisations can be reproduced using SAS tools.

11:15, 12th May 2021

R U Graphing with SAS?

Here is an exploration of how graphs produced using the popular R package GGPLOT2 compare with those created using SAS tools, specifically the SGPLOT procedure and Graph Template Language. Using built-in datasets from both systems, scatter plots, box plots and histograms were recreated in SAS to visually match their R counterparts, noting that while default styling differs between the two, both approaches follow a similar layered philosophy for building graphics.

Simple graphs are straightforward in either system, and more complex ones are achievable, though GGPLOT2 favours brevity in its syntax while SAS opts for a more structured and verbose approach. The developer also observed that grouped histograms, supported natively in GGPLOT2, are not directly available in SAS at the time of writing, requiring a workaround using overlaid histograms from reshaped data.

11:07, 12th May 2021

Comparing Dataframes In R Using compareDF

The compareDF package for R, developed to address gaps in existing data comparison tools, provides a straightforward way to identify and summarise differences between two dataframes that share the same structure. Its core function, compare_df, accepts two dataframes alongside one or more grouping variables and produces several outputs, including a comparison table that highlights rows where at least one value has changed, a colour-coded HTML output where changed cells are marked in red for older values and green for newer ones, and summary objects that quantify the number of changes, additions and removals per group.

The package supports grouping by multiple columns, allowing distinctions to be made between records that share a name but belong to different categories. Additional parameters enable users to exclude specific columns from comparison, limit the number of rows rendered in the HTML output to avoid performance issues with large datasets and set a numeric tolerance threshold so that minor variations below a defined percentage are not flagged as meaningful changes. Rows that are identical across both dataframes are omitted from the output entirely, keeping results focused on genuine differences.

11:07, 12th May 2021

Quick Intro to Parallel Computing in R

Parallel computing in R offers a powerful way to speed up data-heavy computational tasks by distributing workloads across multiple processor cores. Modern computers contain multiple cores, and while R has historically been single-threaded, packages such as parallel and foreach allow programmers to take advantage of this additional processing power. Sequential loops and standard apply functions process tasks one at a time, but functions like mclapply and the dopar operator in the foreach package enable the same tasks to run simultaneously across multiple cores, significantly reducing overall computation time.

This approach is particularly valuable when processing large datasets, such as those involving remote sensing or complex environmental modelling, where hundreds of thousands of files may need to be handled. However, parallelisation is not always the most efficient solution, as there is inherent overhead in copying data and spawning new processes, meaning that for shorter or less intensive tasks, the setup costs can outweigh the performance gains. The proportion of a task that can actually be parallelised also affects efficiency, a concept related to Amdahl's Law, which suggests that speedup diminishes as the non-parallelisable portion of a task grows.

11:05, 12th May 2021

Sharing Your Work with xaringan

A four-hour online workshop held across two days in November 2020 introduced R users to the xaringan package as a tool for building and sharing presentation slides via HTML. The first session covered the fundamentals of creating slides and deploying them in a shareable format, while the second explored advanced customisation using CSS and the xaringanExtra package. Designed for those already familiar with R Markdown and GitHub, the workshop was delivered through RStudio Cloud and Zoom, with local installation of R, RStudio and several packages available as a backup. The workshop was created by Dr Silvia Canelón of the University of Pennsylvania for the NHS-R Community 2020 Virtual Conference, drawing on prior work by Alison Hill and Greg Wilson.

11:03, 12th May 2021

ggplot2 - Easy Way to Mix Multiple Graphs on The Same Page

Combining multiple ggplot2 graphs onto a single page or across multiple pages requires specialist approaches, as standard R functions such as par() and layout() are incompatible with ggplot2. Several R packages offer solutions to this challenge, including gridExtra, cowplot and ggpubr.

The gridExtra package provides functions for arranging plots in a grid format, though it does not align plot panels or axes. The cowplot package addresses axis alignment through its plot_grid() function but lacks support for multipage layouts. The ggpubr package bridges this gap with its ggarrange() function, which wraps cowplot functionality while adding support for multipage arrangements and shared legends.

Beyond basic arrangement, these tools collectively support a range of more advanced layout techniques, including nested arrangements, custom column and row spanning, annotated figures, scatter plots with marginal density plots and the embedding of tables, paragraphs or additional graphical elements within a plot. Background images can also be incorporated into ggplot2 graphics using the background_image() function from ggpubr. Completed arrangements can be exported to file formats such as PDF, EPS or PNG using the ggexport() function, with options to control how many plots appear on each page.

  • 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.