It will run without the COUNT() statement but with it there, it won't run. It's so frustrating; I can't figure out why! TMISSING variable has either 'YES' or 'NO' and I want to count how many YES's per cycle per person (ID_NUM).
CREATE TABLE SUBJECT AS
SELECT DISTINCT ID_NUM AS ID, CYCLE LENGTH=5, TMISSING LENGTH=8,
COUNT(DISTINCT TMISSING='YES') AS COUNT LENGTH=5
GROUP BY ID_NUM, CYCLE;
PROC PRINT DATA=SUBJECT;
COUNT(DISTINCT TMISSING='YES') should return 2 since the distinct values of the logical result of (TMISSING='YES') would be True and False. so 2 distinct values.
SUM(DISTINCT TMISSING='YES') should give you what you want
For simple counting reports, I always turn to PROC FREQ. For example, if I want to know how many products were sold for each REGION in SASHELP.SHOES, I can do this, using BY group processing:
proc sort data=sashelp.shoes out=shoes;
ods html file='c:\temp\shoe_count.html' style=sasweb;
proc freq data=shoes;
ods html close;
Just as you can have more variables listed in a GROUP BY for PROC SQL, you can have more than one BY variable used for BY group processing. So your PROC FREQ could have BY ID_NUM CYCLE for your PROC FREQ.