DATA Step, Macro, Functions and more

SAS

Reply
Occasional Contributor
Posts: 17

SAS

There is dataset with 4 variable  ID,Height Weight , Age. This dataset contain 100 enteries. In this data set there are missing value. I want to explore and clean dataset. I did proc means that gives me n, mean, std,min, max. But I want table which show me n, mean, std,min, max, nmiss, number of missing values, percentage of missing value, number of dropped variable. How can I write macro for this also.

Super User
Posts: 24,012

Re: SAS

Posted in reply to librasantosh

It’s not clear what you’re asking for here. 

To write a macro you should start with working base code, please include what you have so far and explain how/why you need a macro so we can make the appropriate recommendations. 

 


librasantosh wrote:

There is dataset with 4 variable  ID,Height Weight , Age. This dataset contain 100 enteries. In this data set there are missing value. I want to explore and clean dataset. I did proc means that gives me n, mean, std,min, max. But I want table which show me n, mean, std,min, max, nmiss, number of missing values, percentage of missing value, number of dropped variable. How can I write macro for this also.


 

Super User
Posts: 13,941

Re: SAS

Posted in reply to librasantosh

what is the difference between nmiss, "number of missing values" and "dropped variable"?

 

NMISS is the number of records with missing values.

 

proc summary data=have;
   var _numeric_;
   output out=havesum n= mean= std= min= max= nmiss= /autoname;
run;

Will create a data set summarizing all of the numeric variables (or list yours of interest) and creates summary statistics with the statistic name added to the variable name to create unique names. There will also be an automatic variable named _freq_ that has the record count.

 

 

Percentages could be calculated in a data step diving any of the count values (n or nmiss) by dividing by _freq_;

 

There is likely no need for a macro at all.

Super User
Posts: 10,574

Re: SAS

Posted in reply to librasantosh

You have been told repeatedly(!) to use more descriptive subject lines. Using just "SAS" in the main SAS forum of the world is quite lacking of intelligence.

 

Please improve on that and use the edit function to give your post a more descriptive subject line. Please.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 3 replies
  • 90 views
  • 0 likes
  • 4 in conversation