BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
AJYass
Calcite | Level 5

Hello,

 

I am not sure how to do what I want. Basically I have a group variable of organizations I am interested in, I would like to look across the data set see how many variables are empty for each organization.

 

So like data I have:

ORGVar1 Var2 Var3
OrgA.10
OrgB110
OrgC...

 

Want:

ORGCount of Missing Var
OrgA1
OrgB0
OrgC3

 

I have about 40 organizations in the group variable and about 200 variables total.

 

Thanks in advance!

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User
data want;
   set have 
   Countofmissing= cmiss(Var1, var2, var3);
run;

should do it.

If you have lots more variables there may be ways to shorten the syntax with variable lists but we would have to see a more complete description of your data.

View solution in original post

5 REPLIES 5
ballardw
Super User
data want;
   set have 
   Countofmissing= cmiss(Var1, var2, var3);
run;

should do it.

If you have lots more variables there may be ways to shorten the syntax with variable lists but we would have to see a more complete description of your data.

AJYass
Calcite | Level 5

I do have a lot more variables, I need to look at them all. What info do you think we need?

 

I tried

proc sort data = Have; by Org; run;

data want;
set Have;
Countofmissing= cmiss(Var1-Var200);
by Org;
run;

 

But it did not work, the new Countofmissing wasnt counting. They were all equal to 1.

ballardw
Super User

@AJYass wrote:

I do have a lot more variables, I need to look at them all. What info do you think we need?

 

I tried

proc sort data = Have; by Org; run;

data want;
set Have;
Countofmissing= cmiss(Var1-Var200);
by Org;
run;

 

But it did not work, the new Countofmissing wasnt counting. They were all equal to 1.


You subtracted variable Var200 from Var1.

Use  :  cmiss( OF var1-var200);

or if all of your variables are actually named like that

   cmiss (of var:)

the : is a list builder that says "use all the variables whose names start with VAR (or whatever characters you supply).

 

AJYass
Calcite | Level 5

OH! Okay thanks for point that out.


They are all uniquely named variables unfortunately.

The first is A1_1 and the final is Vstatus so the code should be

 

data want;
set have;
Countofmissing= cmiss(OF A1_1-Vstatus);
run;

 

Is that correct? Thanks so much for all the help!

ballardw
Super User

If you use a list like "of thisvar -- thatvar" , note there are 2 dashes, then SAS uses the variable positions to build the list and gets all of the variables starting at thisvar and ending at thatvar.

 


@AJYass wrote:

OH! Okay thanks for point that out.


They are all uniquely named variables unfortunately.

The first is A1_1 and the final is Vstatus so the code should be

 

data want;
set have;
Countofmissing= cmiss(OF A1_1-Vstatus);
run;

 

Is that correct? Thanks so much for all the help!


 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 5 replies
  • 151 views
  • 0 likes
  • 2 in conversation