BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chennupriya
Quartz | Level 8
Thank you for all help
chennupriya
Quartz | Level 8
Also , i have both character and numeric variables in the Dataset
PaigeMiller
Diamond | Level 26

@chennupriya wrote:

I wanted to check how do i apply the code to check percentage missing of all variables by Category A Category B and Category C

The first step in any macro writing ought to be to create working SAS code without macros and without macro variables, for a single data set. Once you have done that, turning the results into a macro will be relatively simple. But it doesn't appear you have done that yet.

--
Paige Miller
Ksharp
Super User

It is easy for PROC SQL.

Make a macro to make the following code streamline .

 

data have;
set sashelp.heart;
if ranuni(1) < 0.2 then call missing(AgeAtStart,status);
run;

proc sql;
create table want as
select sex,
 nmiss(AgeAtStart)/count(*) as nmiss_per_AgeAtStart,
 nmiss(status)/count(*) as nmiss_per_status,
 nmiss(height)/count(*) as nmiss_per_height
from have
 group by sex;
quit;
Tom
Super User Tom
Super User

It seems silly to use NMISS() with only one variable.  That is what MISSING() is for.  But it won't actually do what you want since either is just going to operate on each observation and not aggregrate.

 

Instead just use the COUNT() function of SQL.  It will not count the missing values of the variable given.

,count(AgeAtStart)/count(*) as AgeAtStart
,count(status)/count(*) as status
,count(height)/count(*) as height

Plus that way the code should easier for SAS to push into a remote database.

chennupriya
Quartz | Level 8
Sure . Thank you I can try that code and see if it works
chennupriya
Quartz | Level 8
Thank you for all your help
chennupriya
Quartz | Level 8
Thank you everyone so much for all your help .

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 23 replies
  • 2465 views
  • 11 likes
  • 7 in conversation