Count

Accepted Solution Solved
Reply
Valued Guide
Posts: 860
Accepted Solution

Count

I would like to add a variable that counts the number of variables each row has in a dataset, in excel I use =COUNT(B2Smiley Very Happy2) to get the desired result.  Can someone help to do this in SAS?  I have 4 variables, pcpid, date2011,date2012, date2013.  I want to have a count from 0-3 regarding the dates.  If something was returned from a pcp the date field will be populated.  I will then sort by the count field to have the pcp that returned all three surveys at the top.

Thanks,

Mark


Accepted Solutions
Solution
‎09-24-2013 01:33 PM
Super User
Posts: 19,802

Re: Count

Posted in reply to Steelers_In_DC

Assuming that date columns are actually SAS date variables, use the n() function.

n(date2011, date2012, date2013);

or

n(of date2011-date2013);

View solution in original post


All Replies
Solution
‎09-24-2013 01:33 PM
Super User
Posts: 19,802

Re: Count

Posted in reply to Steelers_In_DC

Assuming that date columns are actually SAS date variables, use the n() function.

n(date2011, date2012, date2013);

or

n(of date2011-date2013);

Valued Guide
Posts: 860

Re: Count

Thanks, I was using transpose and count() then trying to merge back and not getting what I wanted.  I thought there was a simpler way that I was missing.

Thank You,

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 177 views
  • 0 likes
  • 2 in conversation