Tag: Macro Programming

Using %IF-%THEN-%ELSE in SAS programs

SAS programmers have long wanted the ability to control the flow of their SAS programs without having to resort to complex SAS macro programming. With SAS 9.4 Maintenance 5, it’s now supported! You can now use %IF-%THEN-%ELSE constructs in open code. This is big news — even if it only […]

The post Using %IF-%THEN-%ELSE in SAS programs appeared first on The SAS Dummy.

How to read the contents of a file into a SAS macro variable

I’ve been working on a SAS program that can add content to the SAS Support Communities (more on that in a future post). Despite my 20+ years of SAS experience, there are a lot of SAS programming tricks that I don’t know. Or that I use so infrequently that I […]

The post How to read the contents of a file into a SAS macro variable appeared first on The SAS Dummy.

How to split one data set into many

Back in the day when the prison system forced inmates to perform “hard labor”, folks would say (of someone in prison): “He’s busy making little ones out of big ones.” This evokes the cliché image of inmates who are chained together, forced to swing a chisel to break large rocks […]

The post How to split one data set into many appeared first on The SAS Dummy.

Put them back the way you found them: restoring SAS titles

Has this ever happened to you? You have a SAS program with statements that you wrote, then you make use of a macro function or %include file supplied by a helpful colleague, and when your SAS code resumes, you find that all of your SAS titles have been changed out […]

Copy a file using a SAS program: another method

A couple of years ago I shared a method for copying any file within a SAS program. It was a simple approach, copying the file byte-by-byte from one fileref (SAS file reference) to another. My colleague Bruno Müller, a SAS trainer in Switzerland, has since provided a much more robust […]

How to find the ENGINE name for a SAS library

One of the great things about SAS libraries is that you can write your programs to read and write data without having to worry about where the data lives. SAS data set on a file system? Oracle table in a database server? Hadoop data in Hive? For many SAS applications, […]

An FTP-style task in SAS Enterprise Guide: user-driven fixes

A few months ago I released the Copy Files task for use with SAS Enterprise Guide. The task allows you to transfer any files between your PC and a SAS Workspace session, much like an FTP process. It doesn’t rely on FTP though; it uses a combination of SAS code, […]

Improving on a SAS programming pattern

Earlier this week I described a common programming pattern in the SAS macro language. The pattern sets up a loop for processing each distinct value of a classification variable. The program uses the PROC SQL SELECT INTO feature to populate SAS macro variables. The effect: you can roll your own […]