02-28-2017 02:18 AM
I'm trying to set up a proc freq function where I am looking at counts of a certain screening done by location. In my dataset, I have a column called DCdeathdate which basically indicates what date the entry was stored and it is stored in this fashion "01/01/2017". My dataset spans 3 months (Nov, Dec, Jan). How do I generate a proc freq where I'd like to look at the number of counts by location in 3 different dates? I used this but it looks like its giving me every individual date that has shown up in the dataset. Thanks for your help!
proc freq data=mydata.inptdatamainfile order=freq; tables dcdeathdate*_OrganizationName*hepcscreeningdone / nocol nopercent; where _organizationregion='Adjara'; run;
02-28-2017 03:16 AM
Can you provide a little test data, and how you would like the output to look please? It'll make it much easier. Otherwise it's a bit guessworky.
02-28-2017 03:28 PM
Simply by using a format on dcdeathdate in your proc freq, the accumulation will be at the monthly level you require. I created some random data to show it:
data inptdatamainfile; attrib dcdeathdate length=4 format=ddmmyy10.; attrib _OrganizationName length=$ 30; attrib hepcscreeningdone length=$ 3; do i = 1 to 1000; dcdeathdate = (int(ranuni(0) * 120)) + ('1nov2016'd) + 1; hepcscreeningdone = ifc(ranuni(0) > .5, 'Yes', 'No'); _OrganizationName = 'Organisation ' || byte(int(ranuni(0) * 4) + 1 + 64); output; end; keep dcdeathdate _OrganizationName hepcscreeningdone; run; proc freq data=inptdatamainfile order=freq; table dcdeathdate*_OrganizationName*hepcscreeningdone / nocol nopercent; format dcdeathdate monyy7.; run;
02-28-2017 03:35 AM
To provide test data, use a data step as described here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...