Many SAS programmers use macros. I have seen students in my SAS classes use several methods to activate their macros. One way is to load the macro in the Display manager or editor in SAS OnDemand for Academics and submit it. Another technique is to use the statement %Include macro-name.
Tag: SAS macro
Last year, I wrote a blog demonstrating how to use the %Auto_Outliers macro to automatically identify possible data errors. This blog demonstrates a different approach—one that is useful for variables for which you can identify reasonable ranges of values for each variable. For example, you would not expect resting heart
In many programming languages, there is a function named eval() that can be used to evaluate an expression and return the result at run time. For example, in Python, the eval() function parses the expression passed to it and runs a Python expression or code within the program. Even Python
SAS Press author Kim Chantala shows you how to to spend less time preparing data so you can lavish time on analysis.
In my new book, End-to-End Data Science with SAS: A Hands-On Programming Guide, I use the 1.5 IQR rule to adjust multiple variables. This program utilizes a macro that loops through a list of variables to make the necessary adjustments and creates an output data set. One of the most
SAS' Leonid Batkhan describes programming technique for creating multi-purpose SAS® Macro functions.
SAS' Leonid Batkhan differentiates between SAS macro and programming languages, defines two types of SAS macros and much more.
Suppose you want a list of car manufacturers from the CARS dataset. Easy! Call the %CHARLIST macro from a %PUT statement, like this: The CHARLIST macro generates a list of unique values of a selected variable from a selected dataset. So does PROC FREQ. But, if you don't need statistics, the CHARLIST
The stored compiled macro facility enables you to compile and save your macro definition in a permanent catalog in a library that you specify. The macro is compiled only once. When you call the macro in the current and subsequent SAS® sessions, SAS executes the compiled code from the macro
SAS® offers several ways that you can find the top n% and bottom n% of data values based on a numeric variable. The RANK procedure with the GROUPS= option is one method. Another method is The UNIVARIATE procedure with the PCTLPTS= option. Because there are several ways to perform this
Have you ever written a macro and wondered if there was an easy way to pass values to the macro? You can by using macro parameters. Macro parameters enable you to pass values into the macro at macro invocation, and set default values for macro variables within the macro definition.
When developing SAS applications, you can feed database tables into your application by using the libname access engine either by directly referring a database table, or via SAS or database views that themselves refer to one or more of the database tables. More on Automation with SAS: Let SAS write
As technology expands, we have a similarly increasing need to create programs that can be handed off – to clients, to regulatory agencies, to parent companies, or to other projects – and handed off with little or no modification needed by the recipient. Minimizing modification by the recipient often requires
Have you ever needed to run code based on the client application that you are using? Or have you needed to know the version of SAS® software that you are running and the operating system that you are running it on? This blog post describes a few automatic macro variables
I started young. Since I was 9 years old, I’ve always loved cooking delicious, tasty and healthy food, and feeding friends and family. My aunt still remembers the delicious chocolate soufflé that trembled and shook but would never collapse that I made for them when I was 18! Word spread.
A recent post, Jedi SAS Tricks: The DATA to DATA Step Macro, engendered a lot of response on Twitter. One of the re-tweets included a call to action - make this a button in Base SAS!
I was answering questions about SAS in a forum the other day, and it struck me how much easier it is to help folks if they can provide a snippet of data to go along with their program when asking others to help troubleshoot. This makes it easy to run
In my previous post, Introducing data-driven loops, I suggested a way of implementing programming loops with a list of index variables pulled from an external data table. These ordinary programming loops iterate during code execution while processing some data elements of an input data table. SAS macro loops, on the
This SAS author tip is from Robert Virgile, author of “SAS Macro Language Magic: Discovering Advanced Techniques”. It actually came about when a reader posted a comment on one of Virgile’s blogs. Thank you to that reader for their comment! Technically, %INCLUDE is not part of macro language. Yes, it
SAS Global Forum brings together the most die-hard SAS users, both veteran and novice, once a year. It’s one of those can’t-miss events, and each year it just gets better. 2015 will bring us all together in Dallas, Texas for several days of active learning and excitement from SAS users
Order must be the most frequent cry for help in the SAS classroom. “HELP,” said my student in the classroom. “I work with messy health data. My users want to see data in this order.” T1.col1, t1.col2, t1.col3, t1.col4, t2.col5, t1.col6 and list the remaining columns in column position from
Sometimes, your first impulse may not be correct, like trading in your practical sedan for a hot 2-seater. Other times, your first impulse is perfect, as in the examples below. Suppose the automobile data you wish to analyze resides in a CSV file. Naturally, your first impulse is to import
Suppose you have an old jalopy that's perfectly reliable. Your jalopy gets you where you wanna go: no frills; no drama. Do you trade your old wheels in for a racecar that accelerates like crazy and corners like it's on rails? Or stick with what's old and comfortable? Your choice