count

Accepted Solution Solved
Reply
Valued Guide
Posts: 860
Accepted Solution

count

Hello, I intended to use the below code so that 'count' would be a value showing similar results to 'frequency' in a proc freq table.  If you can look through it and see any glaring errors please let me know.  The results I'm getting is just a count of the entire population like _n_, it's not resetting the counter by every pcpid.

Thanks,


data link;

merge     all_n (in=a rename=(pcp_id=pcpid))

              all_data (in=b);

by pcpid;

count+1;

if first.pcpid then do count=1;

end;

if last.pcpid then output;

run;


Accepted Solutions
Solution
‎10-07-2013 05:50 PM
Super User
Super User
Posts: 7,039

Re: count

Posted in reply to Steelers_In_DC

Or just eliminate the DO END since you only have one statement in the THEN clause.

count+1;

if first.pcpid then count=1;

if last.pcpid then output;

View solution in original post


All Replies
Frequent Contributor
Posts: 129

Re: count

Posted in reply to Steelers_In_DC

You are missing a semicolon in the do statement;

You want

if first.pcpid then do ;

   count = 1 ;

end ;

HTH

Solution
‎10-07-2013 05:50 PM
Super User
Super User
Posts: 7,039

Re: count

Posted in reply to Steelers_In_DC

Or just eliminate the DO END since you only have one statement in the THEN clause.

count+1;

if first.pcpid then count=1;

if last.pcpid then output;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 231 views
  • 3 likes
  • 3 in conversation