Creating All Possible Combinations in a Table Using SAS

前端 未结 3 1462
一生所求
一生所求 2020-12-11 09:16

I have a table with four variables and i want the table a table with combination of all values. Showing a table with only 2 columns as an example.

NAME    AM         


        
3条回答
  •  猫巷女王i
    2020-12-11 09:44

    There are a couple of useful options in SAS to do this; both create a table with all possible combinations of variables, and then you can just drop the summary data that you don't need. Given your initial dataset:

    data have;
    input NAME $ AMOUNT  COUNT;
    datalines;
    RAJ 90  1
    RAVI    20  4
    JOHN    30  5
    JOSEPH  40  3
    ;;;;
    run;
    

    There is PROC FREQ with SPARSE.

    proc freq data=have noprint;
    tables name*amount*count/sparse out=want(drop=percent);
    run;
    

    There is also PROC TABULATE.

    proc tabulate data=have out=want(keep=name amount count);
    class name amount count;
    tables name*amount,count /printmiss;
    run;
    

    This has the advantage of not conflicting with the name for the COUNT variable.

提交回复
热议问题