Apr 23, 2013

Concatenate Strings the Smarter way with CAT / CATX / CATT functions...

Here are the Definitions of these functions…
CAT() – Concatenates character strings without removing leading or trailing blanks
CATX() – Concatenates character strings, removes leading and trailing blanks, and inserts separators
CATT() – Concatenates character strings and removes trailing blanks
CATS() – Concatenates character strings and removes leading and trailing blanks, no seperators
The results of the CAT, CATS, CATT, and CATX functions are usually equivalent to those that are produced by certain combinations of the concatenation operator (||) and the TRIM and LEFT functions. However, using the CAT, CATS, CATT, and CATX functions is faster than using TRIM and LEFT, and you can use them with the OF syntax for variable lists in calling environments that support variable lists…
Read more in the SAS Documentation below with examples….

 
 
 

Apr 16, 2013

Use a Microsoft Excel file to create a user-defined format




A document that discusses Use a Microsoft Excel file to create a user-defined format


/*Create an Excel spreadsheet for the example. */

filename test 'c:\testfmt.csv';

proc export data=sashelp.class outfile=test

  dbms=csv replace;

run;

 

/* Read the Excel spreadsheet and create a SAS data set. */

proc import datafile=test out=work.testfmt dbms=csv replace;

run;

 

/* Build control data set */

data new(drop=sex);

   retain fmtname 'testfmt' type 'C';

   length label $6.;

   set testfmt;

   rename name=start;

   if sex='M' then label='Male';

   else label='Female';

run;

 

/* Create the format using the control data set. */

proc format cntlin=new;

run;

 

/* Use new format to display average height by gender */

title;

ods listing close;

ods html file="c:\myfile.htm" style=styles.meadow;

 

proc report data=sashelp.class nowd;

   title 'Using Control Data Set to generate a format with Excel file';

   column name height;

   define name / group f=$testfmt.;

   define height / mean 'Average Height' f=6.2;

run;

 

ods html close;

ods listing ;