BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
BrahmanandaRao
Lapis Lazuli | Level 10
data colmiss_ds ;
infile datalines truncover;
input x y z a$  b$ ;
datalines;
1   . 66      BB 
2  55  . 
3   .  .  CC  DD
4  55  . 
;
run;


options symbolgen;

%macro xyz(new_ds,exist_ds,nvar,charvar);
data &new_ds;
set &exist_ds;
if nmiss(&nvar))=. then output;
if cmiss(&charvar))= '' then output;
%mend;

%xyz(dsn,colmiss_ds,nvar,charvar);

how to get numeric and character  missing count using macro application

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

As Kurt said no need macro at all.

 

data colmiss_ds ;
infile datalines truncover;
input x y z a$  b$ ;
datalines;
1   . 66      BB 
2  55  . 
3   .  .  CC  DD
4  55  . 
;
run;

proc transpose data=colmiss_ds(obs=0) out=temp;
var _all_;
run;
proc sql noprint;
select catx(' ','nmiss(',_name_,') as',_name_) into :missing separated by ',' from temp;
create table temp2 as select &missing. from colmiss_ds;
quit;
proc transpose data=temp2 out=want;
run;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

Before you engage in macro programming, start with working non-macro code.

So get rid of all the macro stuff and write a simple step which does what you do.

To get hints for this, also post the expected result for your example data.

Ksharp
Super User

As Kurt said no need macro at all.

 

data colmiss_ds ;
infile datalines truncover;
input x y z a$  b$ ;
datalines;
1   . 66      BB 
2  55  . 
3   .  .  CC  DD
4  55  . 
;
run;

proc transpose data=colmiss_ds(obs=0) out=temp;
var _all_;
run;
proc sql noprint;
select catx(' ','nmiss(',_name_,') as',_name_) into :missing separated by ',' from temp;
create table temp2 as select &missing. from colmiss_ds;
quit;
proc transpose data=temp2 out=want;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 449 views
  • 1 like
  • 3 in conversation