Folks,
I'm carrying out some analysis to produce counts by different categories. I'm using the following code;
/*Board Ages*/
proc summary data = full_dataset_3 nway missing;
;
format year_filed year_filed. county_y $county_y. age_filed_total age_filed_total. ;
class year_filed county_y age_filed_total /mlf;
var Number_Person;
output out = Number_of_people (drop=_freq_)
sum= ;
run;
However, I need to do some disclosure control so nothing can be identified. Any value which is less than 20 will get set to zero and I want to round all values to the nearest tenth e.g. 255 gets rounded to 260 and 123 gets rounded to 120.
However, I would also like my subtotals to add up to the total e.g. when I round all the subtotals I need to recalculate the totals again.
Basically I need to go from my original data to this new one. Would anyone be able to provide some guidance? I would rather round cells rather than suppressing.
data example;
length year $4. location $11. cohort $17.;
input year $ location $ cohort $ org rounded;
infile datalines delimiter=',';
datalines;
2010,All regions,: All ages,1657,1650
2010,All regions,100 0 - 24 years,27,20
2010,All regions,101 25 - 35 years,266,270
2010,All regions,102 36 - 45 years,299,300
2010,All regions,103 46 - 59 years,246,240
2010,All regions,104 60+ years,121,120
2010,All regions,105 Unknown,698,700
2010,Region A,: All ages,453,440
2010,Region A,100 0 - 24 years,22,20
2010,Region A,101 25 - 35 years,149,150
2010,Region A,102 36 - 45 years,99,100
2010,Region A,103 46 - 59 years,83,80
2010,Region A,104 60+ years,32,30
2010,Region A,105 Unknown,75,80
2010,Region B,: All ages,365,670
2010,Region B,100 0 - 24 years,5,0
2010,Region B,101 25 - 35 years,117,120
2010,Region B,102 36 - 45 years,200,200
2010,Region B,103 46 - 59 years,163,160
2010,Region B,104 60+ years,89,90
2010,Region B,105 Unknown,623,620
;
run;
However, I need to do some disclosure control so nothing can be identified. Any value which is less than 20 will get set to zero and I want to round all values to the nearest tenth e.g. 255 gets rounded to 260 and 123 gets rounded to 120.
You need to run the output of PROC SUMMARY through another DATA step to do the rounding, and to set any value less than 20 to zero.
However, I would also like my subtotals to add up to the total e.g. when I round all the subtotals I need to recalculate the totals again.
Then you run PROC SUMMARY again on the rounded/truncated data.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.