Tag: howto

Checking return codes for errors in SAS

You should check for error return codes in any SAS programs that run unattended in batch jobs, so you can handle the exception properly. For example, if the data are invalid, you don’t want to generate reports or insert bad data into a database. …

Model decision tree in R, score in SAS

This code creates a decision tree model in R using party::ctree() and prepares the model for export it from R to SAS, so SAS can score new records without invoking R. I use this method for several reasons. First, it’s convenient for my workflow t…

Programmatically download monthly economic indicators

This SAS code programmatically downloads monthly economic indicators from FRED, and merges multiple time series into a single data set for convenient analysis. FRED (Federal Reserve Economic Data) is an excellent resource from the Federal Reserve Bank …

Delete non-exact duplicates in SAS

When deleting non-complete duplicates in SAS, in each duplicate set you may want to keep a particular record identified by a rule: it may be the oldest, newest, first, or last observation in each set. You need a identifier to be unique, but you can&#82…

C# Dictionary of US State Abbreivation to Names using SAS

I need C# code to convert United States state postal abbreviations (like AL) to full state names (like Alabama), but I’m afraid of making a typo retyping the abbreviation list from the USPS—and that just seems tedious. However, it’s e…

Strip Non-Printable ASCII Characters (SAS)

Say in your SAS data set, which comes from a text file, XML, or database, has non-ASCII characters that look like garbage—perhaps an odd square. These are probably control characters that mean something to some system, but they may be useless to …

Import DBF in SAS

There are several ways to import DBF files in SAS. First, there is PROC DBF: filename dbfin ’employee.dbf’; proc dbf db5=dbfin out=employee; run; But in my environment (SAS 9.1.3 Windows XP; and SAS 9.2 on Windows Server 2008 with Enterprise Guide 4.2 …