Sunday, February 28, 2016

Display all categories on CRF even there is no count

Very often in a statistical summary table for a variable (such as race, age group), we will need to display all categories listed on the case report form even through there may be no subject falling into one of the categories.

See paper by Phillips and Klein "Oh No, a Zero Row: 5 Ways to Summarize Absolutely Nothing" for discussions of various ways in handling this.

SPARSE option in PROC FREQ for filling the data set

The SPARSE Option The SPARSE option in PROC FREQ is not properly named. It is neither meager nor thin in its ability. It is a very powerful option in the table statement. Simply stated, the SPARSE option provides “all possible combinations of levels of the variables in the table, even when some combination levels do not occur in the data.”1 This is a huge help when trying to zero-fill a data set. Although current versions of SAS® now contain the new PRELOADFMT option for TABULATE and REPORT, for some types of reports, this new option will not work.

See the article by Chris Moriak

Monday, February 1, 2016

How to find a character or word from a free text variable?

It is often difficult to summarize the information from a free text variable. If we do, it may require to identify / find the character or word using a SAS function.

SAS function Index() can be used for this purpose. The following statement will identify any records with the word 'PNEUMONIA' contained in the VARNAME variable.

       where index(varname, 'PNEUMONIA')>=1;

if the word we need to find has mixed lower and upper cases, we can use the upcase() function.

       where index(upcase(varname), 'PNEUMONIA')>=1;

How can I find things in a character variable in SAS?