BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Steelers_In_DC
Barite | Level 11

I would like to add a variable that counts the number of variables each row has in a dataset, in excel I use =COUNT(B2:D2) 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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

2 REPLIES 2
Reeza
Super User

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

n(date2011, date2012, date2013);

or

n(of date2011-date2013);

Steelers_In_DC
Barite | Level 11

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,

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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