0
votes

In SAS, Proc HPBIN, OUTPUT option does not keep original variables as explained below

OUTPUT=SAS-data-set creates an output SAS data set in single-machine mode or a database table that is saved alongside the distributed database in distributed mode. The output data set or table contains binning variables. To avoid data duplication for large data sets, the variables in the input data set are not included in the output data set.

--> How can I keep original variables and bin number?

1

1 Answers

0
votes

Do a 1:1 merge of the output data set with the input data set.

For example:

proc hpbin data=sashelp.orsales noprint out=profitbinned;
  var profit;
run;

data want;
  merge sashelp.orsales profitbinned;
  * 1:1 merge does not have a BY statement;
run;

If the input data has a primary, or unique key, you can specify those key variables in an ID statement to ensure a more robust post-binning merge:

proc hpbin data=sashelp.citiday noprint out=dowcmp_binned;
  var SNYDJCM;
  id date;
run;

proc sql;
  create table want as 
  select bin.date, ticker.SNYDJCM, bin.bin_SNYDJCM
  from sashelp.citiday as ticker
  join work.dowcmp_binned as bin
  on ticker.date = bin.date
  order by bin.date;