Tag Archives: sas

SAS Macro to Read through a Variable List

It is quite often to list different types of variables as strings/variable lists for modeling. For example, you fit your model and get: y_hat = intercept + parest1*var1 + parest2*var2 + … + parestk*vark where k could be as large … Continue reading

Posted in SAS, Statistics | Tagged , , , , , | Leave a comment

Importing .CSV file to SAS

When your data is relatively big, you may save it as .CSV file instead of .XLS or .XLSX. The way to import a .CSV file to SAS is simple too. You may either use PROC IMPORT or a DATA step. … Continue reading

Posted in SAS | Tagged , , , , , , | Leave a comment

Create Heatmap by State using SAS

Visualization is very powerful. One good way to visualize geographical summary is to show heatmap on the map. This article gives an example of creating a simple heatmap by USA state using SAS. 1. Data Sets maps.us: (sample records) maps.uscenter: … Continue reading

Posted in SAS | Tagged , , , , , | Leave a comment

A Simple SAS Macro to Create Deciles

We use deciles very often in marketing segmentation. When the data has no or a very small number of ties in ranking with the variable of interest, it is okay to use PROC RANK for grouping. However if there are … Continue reading

Posted in SAS | Tagged , , , , , , , , , , | Leave a comment

INDEX in SAS

Using index to append additional columns (fields, variables) on a driver file could be a very good choice when dealing with frequently used large data set. Below are several tips I summarized based on my SAS coding experience so far: … Continue reading

Posted in SAS | Tagged , , , , | Leave a comment

Import EXCEL .xlsx/.xls/.xlsm files to SAS through ODBC

Without access to SAS/ACCESS to PC Files, it is okay to import .CSV files to SAS using PROC IMPORT but not for .xlsx/.xls/.xlsm. One alternative way is to use LIBNAME statement through ODBC: http://support.sas.com/kb/32/455.html Example: Suppose we have an EXCEL .xlsx … Continue reading

Posted in SAS | Tagged , , , , , , , | Leave a comment

Automate Your SAS Code Execution

For routine SAS data ETL (Extract, Transform and Load) tasks or those need to be done while we are away from our desks (during late night or very early in the morning), it will save you a significant amount of … Continue reading

Posted in SAS | Tagged , , , , , | Leave a comment

Retrieve Your Unsaved SAS Code

SAS automatically saves code every 10 minutes. If it happens that the window was abnormally closed and a significant portion of code was not saved, you may check the autosaved sas file by searching under C drive for “yoursasfilename.$AS” files, … Continue reading

Posted in SAS | Tagged , , , | Leave a comment

How to extract a sequence of numbers from a string in SAS

Sometime the raw data is messy and we have to extract the information we need. This post will talk about how to take out the numbers we need from a string: If use SAS, the following code may help to … Continue reading

Posted in SAS | Tagged , , , , , , | Leave a comment