Return to Homepage

Goto the Tip of the Month Archive

Other interesting pages ...
LinkedIn Profile
SAS Cheat Sheet
Useful SAS Code
Full SAS Example
Basic Statistics
Contact Information

SAS Tip of the Month
December 2015
(for SAS)

Here is some code that looks okay.

.  proc delete data=work._all_;
   run;
   data dset1;
      name='Tom'; ina='Yes';
      output;
   data dset2;
      name='Tommy'; inb='Yes';
      output; run;
   data _all0;
      merge dset1 dset2;
      by name;
   run;

However output will be a dataset with one record:

  The SAS System

  Obs    name    ina    inb

   1     Tom     Yes    Yes

There is an indication that there is an issue in the SAS LOG, namely

   WARNING: Multiple lengths were specified for the BY variable name by input
            data sets. This may cause unexpected results.

and yes THIS DOES cause unexpected results.

Any WARNING message in your SAS LOG is something you should not ignore.

Another piece of code:

   19   data _null_;
   20   age = 10; *Add a;label
   21   age = age + 5; *Add 5 to age;
   22   run;

   NOTE: DATA statement used (Total process time):
         real time 0.00 seconds
         cpu time 0.00 seconds

What do you think the value of age is after this code is run? If you said 15, then you are wrong - it is actually 10 as the label for AGE is 'age + 5', look at the placement of the second semicolon in the log file line 20 (a LABEL statement does not need quotes around the text, actually it is not needed in the title or footnote statements either!). A warning message will not always appear when there is an issue with the code!

Hope this is useful.

________________________________
Updated December 2, 2015