- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am using SAS 9.4 and have a large data set with various missing data patterns. This is my first time exploring MI in SAS independently, so I ran the below code based on the user guide.
proc mi nimpute=0 data=a out=patterns;
run;
This produced a missing data patterns table with 57 different patterns. Is there a way to sort these patterns in the table, such as by frequency or percentage of pattern, or from least to most missing variables?
I looked through the user guide and could not find any specific option to do this. Also, it doesn't appear the output data set contains any observations to sort by.
It seems this would be helpful to identify patterns and think through approaches to imputation.
Thanks in advance.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can get almost any output table into a data set though it may look a bit different than the displayed version.
The generic skill is learning to use the ODS Trace to determine the name(s) of the created objects the procedure created. Then use that information to write and ODS OUTPUT statement.
Or look up in the documentation for the procedure for the ODS Table Names shown in the Details tab.
Here is an example with Proc freq since I don't have your data.
ods trace on; proc freq data=sashelp.class nlevels; tables sex*age / chisq; run; ods trace off;
The LOG will show the created objects such as:
Output Added: ------------- Name: NLevels Template: Base.Freq.NLevels Path: Freq.NLevels ------------- Output Added: ------------- Name: CrossTabFreqs Label: Cross-Tabular Freq Table Template: Base.Freq.CrossTabFreqs Path: Freq.Table1.CrossTabFreqs ------------- Output Added: ------------- Name: ChiSq Label: Chi-Square Tests Template: Base.Freq.ChiSq Path: Freq.Table1.ChiSq -------------
So if I want to create data sets from the ods output:
proc freq data=sashelp.class nlevels; tables sex*age / chisq; ods output nlevels=work.nlevelset crosstabfreqs= work.mycrosstab chisq = work.mychisq ; run;
If you have a very large data set it is likely worth while to use the data set option OBS= to reduce the number of observations used by the procedure to reduce time for the procedure if you are running it only to get the table names.
Yes, proc freq will create an output data set for the crosstabs. But the ODS OUTPUT will allow placing multiple tables such as tables statement with : Tables (race age sex origin)*( q1 q2 q3 );
Which would require 12 Tables statements to get the cross tabs for all 12 combinations of the variables requested.Ods output will place them all in one set with an indication of which table each row represents.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can get almost any output table into a data set though it may look a bit different than the displayed version.
The generic skill is learning to use the ODS Trace to determine the name(s) of the created objects the procedure created. Then use that information to write and ODS OUTPUT statement.
Or look up in the documentation for the procedure for the ODS Table Names shown in the Details tab.
Here is an example with Proc freq since I don't have your data.
ods trace on; proc freq data=sashelp.class nlevels; tables sex*age / chisq; run; ods trace off;
The LOG will show the created objects such as:
Output Added: ------------- Name: NLevels Template: Base.Freq.NLevels Path: Freq.NLevels ------------- Output Added: ------------- Name: CrossTabFreqs Label: Cross-Tabular Freq Table Template: Base.Freq.CrossTabFreqs Path: Freq.Table1.CrossTabFreqs ------------- Output Added: ------------- Name: ChiSq Label: Chi-Square Tests Template: Base.Freq.ChiSq Path: Freq.Table1.ChiSq -------------
So if I want to create data sets from the ods output:
proc freq data=sashelp.class nlevels; tables sex*age / chisq; ods output nlevels=work.nlevelset crosstabfreqs= work.mycrosstab chisq = work.mychisq ; run;
If you have a very large data set it is likely worth while to use the data set option OBS= to reduce the number of observations used by the procedure to reduce time for the procedure if you are running it only to get the table names.
Yes, proc freq will create an output data set for the crosstabs. But the ODS OUTPUT will allow placing multiple tables such as tables statement with : Tables (race age sex origin)*( q1 q2 q3 );
Which would require 12 Tables statements to get the cross tabs for all 12 combinations of the variables requested.Ods output will place them all in one set with an indication of which table each row represents.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you! I mimicked this and was able to reproduce the table I was after to sort and manipulate otherwise. Very helpful.