Reputation: 2539
I have a table of this form
id1|A|
id1| |var1
id1|B|var2
id2|C|
I would like to count retrieve the data that have all the information for all variables: ie
id1|B|var2
to perform this task I want to count the number of observations in each row and take only the rows which have full observation:
id|name|age |cntrow
id1| A | |2
id1| |var1|2
id1| B |var2|3
id2| C | |2
Any guess how to perform this task?
Upvotes: 0
Views: 453
Reputation: 63424
The n
function would work if this were numeric. Since the data are not, you can use CMISS to find out how many are missing:
data have;
infile datalines dlm='|';
input
id $ charvar1 $ charvar2 $ numvar;
vars_missing = cmiss(of _all_)-1; *because vars_missing is also missing at this point!;
put _all_;
datalines;
id1|A| |3
id1| |var1|2
id1|B|var2|.
id2|C| |2
;;;;
run;
And then subtract that from the known number of variables. If you don't know it, you can create _CHARACTER_
and _NUMERIC_
arrays and use dim()
for those to find out.
Upvotes: 0
Reputation: 518
You can use a CMISS function. Something along the lines of:
Data nomissing missing;
Set input_dataset;
if CMISS(of _ALL_)=0 then output nomissing;
if CMISS(of _ALL_)>0 then output missing;
run;
Upvotes: 1