01-25-2018 08:54 PM
input id days;
if days >=0 and days <=30 then do; range = '0-30'; else
if days >=31 and days <=60 then range ='31-60'; else
if days >=61 and days <=90 then range = '61-90';else
if days >=91 and days <=120 then range = '91-120;
cnt = 1;
In this example nothing would show for the 31-60 category however in that case I want to to show 31-60 with a cnt =0 to reflect this so I can use it in a proc tabulate later on in the program.
01-25-2018 09:46 PM
Deal with that within PROC TABULATE using PRELOADFMT.
If you search those two terms you'll find plenty of examples on how to use it. It will also save you the recoding step, since you can apply the format in PROC TABULATE directly, though you could still recode if you wanted to.
01-26-2018 04:09 AM
You test data soesn't give enough informatio what you want to count.
Check and addapt next code to your needs:
proc format lib=work; value range low - 30 = '0-30' 30 - 60 = '31-60' 60 - 90 = '61-90' 90 - 120= '91-120' other = '***' ; run; data skilton; retain cnt 1; length range $6; range = '0-30'; output; range = '31-60'; output; range = '61-90'; output; range = '91-120'; output; run; data test; input id days; datalines; 1 30 2 90 3 115 ; run; data test2; set test; length range $6; range = put(days,range.); run; proc sort data=test2; by range; run; data to_report; merge skilton test2; by range; if id=. then cnt=0; drop days; run;