Friday, March 19, 2010

Regex search in enhanced editor

Every one has its own habit.

I always edit text in Ultraedit. I like the Regex search/replace functionality in Ultraedit so much as I maintain a list of common Ultraedit-style Regex string.

I know that SAS enhanced editor must have this functionality. However, I got no information for Regex grammar from SAS online doc.

Today, I find the Regex magic box incidentally. :)

Wednesday, March 17, 2010

NOTE: MERGE statement has more than one data set with repeats of BY values

First, the message reminds the user that it is MANY-to-MANY merge in DATA step.

Most SAS progammers are used to ONE-to-ONE or ONE-to-MANY merge since it is easy to understand. When MANY-to-MANY merge occur, the programmer should pay more attention on the data itself.

To perform MANY-to-MANY merge, there are two popular SAS techniques: DATA step and PROC SQL. It should be noted that PROC SQL do not issue the reminder message in MANY-to-MANY merge. Furthermore, it will create a different dataset with the result of DATA step.

Therefore, I suggest that we should perform merge using DATA step.

Sunday, March 14, 2010

To export dataset to excel with label

When we export SAS dataset to excel, we mostly do not like the actual variable name as column name in excel. Alternatively, variable label is more popular.
To export the label before SAS 9.2, we have to use LIBNAME with excel engine since it have many fine options to tune the output, e.g. DBLABEL, DBTYPE etc.

However, when the sheet is existing at that time, they can not be replaced automatically. That means you have to clean the file in advance.

In SAS 9.2, a new options is introduced: LABEL option in PROC EXPORT. The new option allow the output excel take label. Furthermore, PROC EXPORT support REPLACE functionality, that means we may avoid the code to clean the file.