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

Is there a way for me to output all of my tables generated from my PROC FREQ procedure into one dataset?  I'm counting the number of null values in my dataset and would like to know if I can.  Thanks in advance. 

1 ACCEPTED SOLUTION

Accepted Solutions
Hima
Obsidian | Level 7

I'm not sure if this what you are looking for but want to give a shot.

data have;
input id;
datalines;
1
2
3
4
1
2
3
4
5
.
.
.
.
;
run;

proc freq data=have;
tables id /out=want;
run;

Capture.JPG

It would be more helpful if you can throw some data.

View solution in original post

4 REPLIES 4
stat_sas
Ammonite | Level 13

ODS OUTPUT ONEWAYFREQS=want;
proc freq data=have;
table var1 var2;
run;

proc print data=want;
run;

Hima
Obsidian | Level 7

I'm not sure if this what you are looking for but want to give a shot.

data have;
input id;
datalines;
1
2
3
4
1
2
3
4
5
.
.
.
.
;
run;

proc freq data=have;
tables id /out=want;
run;

Capture.JPG

It would be more helpful if you can throw some data.

Reeza
Super User

If you have both character and numeric variables consider this piece of code:

SAS - Missing Macro - For a dataset, variable level report the number of missing and non-missing obs...

if all variables are numeric you can use proc means and the NMISS variable:

proc means data=help stackods n Nmiss;

output out=want ;

run;

MikeZdeb
Rhodochrosite | Level 12

hi ... here's an idea based on a recent posting by Ksharp on how to use PROC SQL to find variables with all missing data (should work for any data set since SQL does all the work of finding the variable names and doing the counting for you) ...

* some data with missing values;

data class;

set sashelp.class;

if ranuni(0) le 0.7 then call missing(age,name);

else if ranuni(0) le 0.4 then call missing(height);

call missing (weight);

run;

* take a look at the amount of missing ;

proc print data=class;

run;

* as suggested by Ksharp ... use NMISS to count missing values;

proc sql noprint;

select cat('nmiss(',strip(name),') as ',name)     into :list separated by ','

  from dictionary.columns

  where libname='WORK' and memname='CLASS';

create table temp as  select &list from class;

select count(*) into :nobs from class;

quit;

* make a report;

data report;

set temp;

array x{*} _numeric_;

do i=1 to dim(x);

  var  = vname(x(i));

  miss = x(i);

  pctmiss = round(100*miss / &nobs, 0.1);

  output;

end;

keep var miss pctmiss;

run;


* look at the results;

proc print data=report

run;

ps  You can also look at "An Easy Route to a Missing Data Report with ODS+PROC FREQ+A Data Step"  ( http://www.lexjansen.com/nesug/nesug11/ds/ds12.pdf   )

though if I were writing that now, I'd replace the use of ODS and PROC FREQ with SQL as suggested by Ksharp (a LOT less programming in the subsequent data step).

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1000 views
  • 1 like
  • 5 in conversation