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

Dear all,

 

I would like to create a table to count the number of non missing values for hundred of columns. My data looks like this:

 

col1 col2 col3 col4 ... col888

1       10     .       5  ...    23

56      .       4      23  ...  44

.         .       .       10  ...  23

1       10     .        5   ...    .

 

The table I would like to have is like this:

col1         3

col2         2

col3         1

col4         4

...

col888     3

 

Really appreciate any help and advice.

Thank you so much!!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Run a PROC MEANS with the NMISS output if they're all numeric.

 

If you need an example, see example 2 and 10 in the PROC MEANS documentation. 

If you still have issues post your code and log.

View solution in original post

4 REPLIES 4
Reeza
Super User

Run a PROC MEANS with the NMISS output if they're all numeric.

 

If you need an example, see example 2 and 10 in the PROC MEANS documentation. 

If you still have issues post your code and log.

Astounding
PROC Star

It is as simple as @Reeza described.  However, you will need to get N (not NMISS) to count nonmissing values.  A simple report:

 

proc means data=have n;

var _numeric_;

run;

 

Getting an output data set instead of a report is just slightly different:

 

proc means data=have noprint;

var _numeric_;

output out=want (drop=_type_ _freq_) n=;

run;

 

However, the shape of that data set might need to be adjusted (depends on how you intend to use it). 

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
  • 4 replies
  • 938 views
  • 1 like
  • 3 in conversation