14:43, 22nd January 2019
How to change your working directory for SAS with the DLGCDIR DATA step function
The DLGCDIR DATA step function in SAS allows users to programmatically change the working directory for their SAS session, applicable to both Windows and UNIX/Linux environments, provided the specified directory exists and has write or update permissions. This function temporarily alters the working directory for the current session, though an autoexec file can be used to automate this change on subsequent SAS invocations. Users are advised to define output directories explicitly in ODS statements, as DLGCDIR does not affect these settings. Some limitations exist, such as the function not influencing directory listings accessed via INFILE pipes or the X command, which may require alternative workarounds like combining commands within the FILENAME statement or using the CALL SYSTEM function to ensure persistent directory changes across operations.
16:45, 16th January 2019
Working with Dates and Times Using the ISO 8601 Basic and Extended Notations
ISO 8601 is a standardised system for representing dates, times, durations and intervals, using a defined set of formatting symbols and notation styles. In SAS, both basic and extended notations are supported, with the basic form using compact sequences such as yyyymmdd or hhmmss, and the extended form introducing separators like hyphens and colons, for example yyyy-mm-dd or hh:mm:ss.
A range of named formats handles the writing of date, time and date-time values, including those with time zone offsets or UTC indicators, while separate formats manage durations and intervals derived from character data. Durations follow a structure beginning with P, with a T separating date and time components, and can be expressed either in fixed-length notation or using labelled components such as years, months and days. Where components are omitted, they can be represented using a hyphen or the letter x depending on the format used, and where lower-order components are zero or insignificant, values may be truncated at the last meaningful component.
SAS also normalises duration components that exceed their standard maximum values, carrying the overflow into the next higher component, though date-time values falling outside expected ranges produce an error rather than being normalised. Ending components in durations, date-time values and intervals may optionally include a fractional element, separated by a period or comma and followed by up to three digits.
11:25, 15th January 2019
Have you created Scalable Vector Graphics with SAS?
Scalable Vector Graphics (SVG) is a vector-based image format supported by modern web browsers that allows graphics to be scaled or resized without any loss of resolution, removing the need to produce multiple versions of the same image. SAS has supported SVG output through its SAS/GRAPH product since the SAS 9.2 release, with compatibility limited to traditional procedures such as PROC GPLOT and PROC GCHART. From SAS 9.3 onwards, Base SAS also gained the ability to produce SVG output through SG procedures like SGPLOT and SGPANEL, as well as through ODS Graphics. Output can be generated as a standalone SVG file, an HTML file or, in SAS 9.4, an HTML5 file with the SVG embedded directly within it. SAS 9.4 also introduced the ability to create animated SVG images for the web using the SVG device driver alongside new options on the OPTIONS statement, with support across a range of procedures including PROC GCHART, PROC GPLOT and PROC GMAP.
14:19, 20th December 2018
Five reasons to use ODS EXCLUDE to suppress SAS output
When working with SAS procedures, suppressing output temporarily is a common requirement, particularly in simulation and bootstrap analyses. Two approaches exist for doing this: the ODS EXCLUDE statement and the ODS CLOSE statement. The ODS EXCLUDE method is generally preferable because it is straightforward to implement, works regardless of which destinations are open, can be easily reversed and repeated multiple times within a single programme and does not alter or overwrite existing output files. In contrast, the ODS CLOSE approach requires the programmer to know which destinations were previously open before reopening them, risks overwriting existing output files and introduces side effects that become increasingly problematic when the process is repeated. While the older practice of using ODS LISTING CLOSE was once common, it is now considered outdated given that the LISTING destination is no longer the default in most modern SAS environments. For programmers seeking a reliable and low-effort way to temporarily suspend SAS output before resuming it later in a programme, ODS EXCLUDE ALL followed by ODS EXCLUDE NONE represents the cleaner and safer solution.
15:56, 5th December 2018
20:31, 24th November 2018
Using WP CLI to run Cron jobs on multisite networks
When running a WordPress multisite network on a self-managed server, disabling the default WordPress Cron system in favour of a server-level Cron job is generally considered good practice. A simple bash script can address the shortcoming of existing approaches, which typically require manual updates whenever a new site is added to the network. The script works by using the WordPress Command Line Interface to retrieve a list of all sites on the multisite network, then loops through each one and runs all due Cron tasks automatically. It can be scheduled to execute on an hourly basis by adding a single line to the server Cron configuration, and the path to the WordPress installation is the only value that needs to be adjusted for it to function correctly. Readers in the comments have also suggested refinements, such as filtering out deleted and archived sites and simplifying the URL retrieval command to remove the need for additional conditional checks.
20:30, 24th November 2018
Properly Setting Up WordPress Cron Jobs
WordPress cron jobs are automated tasks scheduled to run at specified intervals, but unlike traditional Unix cron jobs, they rely on user visits to trigger events, which can lead to delays if traffic is low. To address this, disabling WordPress's default wp-cron system and instead using a Unix-level cron job ensures that tasks execute reliably. This involves defining the event with wp_schedule_event, disabling wp-cron in the wp-config.php file and setting up a cron job via the server's command line or hosting interface to periodically request wp-cron.php, mimicking user activity and ensuring scheduled tasks run on time regardless of site traffic.
21:43, 22nd November 2018
Automatically update your Ubuntu system with cron-apt
Automatically updating an Ubuntu system can be achieved by combining the apt package management system with cron, a task scheduler, to execute regular updates without manual intervention. This involves using commands such as apt-get update and apt-get upgrade, with flags like -y to automate responses and -d to download packages without immediate installation, allowing for later review. The cron-apt package offers a streamlined approach, handling scheduling and providing additional features like email notifications on updates, with configuration details stored in specific system files. This method ensures systems remain secure and up to date by minimising the need for manual checks, while also offering flexibility to monitor and control the update process.
12:04, 17th November 2018
dnstwist is a tool designed to identify potentially malicious domains that may be used for phishing, typo-squatting, or brand impersonation by generating permutations of a given domain name and checking their availability. It employs various fuzzing algorithms, supports Unicode domain names and includes features for detecting phishing websites through fuzzy hashing of web content and perceptual hashing of screenshots. The tool can be installed via package managers, command-line interfaces, or Docker and offers options for exporting results in formats such as CSV or JSON. It is integrated into multiple security platforms and used by organisations for threat intelligence and incident response, providing a method to assess risks associated with domain name variations and potential cyber threats.
13:28, 26th October 2018
The COUNTW function counts the number of words in a character string, with words defined as substrings bounded by specified delimiters or the start/end of the string and the ability to adjust delimiter handling through modifiers. Delimiters can be customised using the chars argument, while modifiers such as M allow counting of zero-length words by treating consecutive or leading/trailing delimiters as word boundaries and Q ignores delimiters within quoted substrings. The function's default delimiters vary between ASCII and EBCDIC environments and it supports null arguments for character inputs. Examples demonstrate how different modifier combinations, such as M and P, influence word counts based on delimiter definitions and string content.