Hi All,
My code:
PROC SQL;
SELECT programtypeid, COUNT(childid) AS NewEnroll_ByCou_YTD
FROM counts
where '01jan2016'd <= dateeval <= &tdate
group by programtypeid;
QUIT;
Gives me this output:
SAS Output
Central Bronx | 2 |
Bronx Park and Fordham | 3 |
High Bridge and Morrisania | 4 |
Hunts Point and Mott Haven | 2 |
Central Harlem | 10 |
Chelsea and Clinton | 1 |
East Harlem | 42 |
The Neighborhoods variable has 35 more categories and I would like them all listed, even if they are all zeros. Is there a way to do this?
Thanks!
The 35 neighborhoods are not in the SAS table or they would have appeared.
Unless you mean that are there but with other dates?
In which case something like this may do:
PROC SQL;
SELECT programtypeid, sum( '01jan2016'd <= dateeval <= &tdate ) AS NewEnroll_ByCou_YTD
FROM counts
group by programtypeid;
QUIT;
Maybe the categories that they don't satify the condition they aren't listed.
I'm going to write another possibility.
PROC MEANS DATA=COUNTS NMISS N;
ID programtypeid;
VAR childid;
OUTPUT OUT=SALIDA(N=NewEnroll_ByCou_YTD); RUN;
PROC SORT DATA=SALIDA;
BY PROGRAMTYPEID;
RUN;
You should include your condition with WHERE;
Do you have a format to transform programtypeid to Neighborhoods?
Untested, assuming that a format exists and is named $Neighborhoods:
proc summary data=counts(where=('01jan2016'd <= dateeval <= &tdate)) completetypes nway; class programtypeid / preloadfmt order=data; format programmtypeid $Neighborhoods.; output out=work.CountComplete(drop=_type_ rename=(_freq_=NewEnroll_ByCou_YTD)); run; proc print data=work.CountComplete noobs; run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.