Help using Base SAS procedures

Proc FREQ - make robust crosstab with different number of vars

Reply
Contributor
Posts: 47

Proc FREQ - make robust crosstab with different number of vars

Hi,

Is there a way to avoid "ERROR: Variable [ ] not found" when requesting a crosstab with Proc Freq? I have to process files with different variables with the same macro code. Sometimes all crosstab vars are present, sometimes 1 is missing.

I could request every possible combination - but was looking for something a bit more sleek.

Thanks.
SAS Super FREQ
Posts: 8,679

Re: Proc FREQ - make robust crosstab with different number of vars

Hi:
Since you are already using a macro program, I'd recommend that you investigate the use of DICTIONARY tables or their SASHELP equivalents. There have been MANY previous forum postings on the use of DICTIONARY tables to select variables (and tables) for processing and many MORE user-group papers on the topic.

cynthia

To get you started:
[pre]
ods listing;

options nocenter ls=175 nodate nonumber;

title 'SQL uses DICTIONARY.COLUMNS';
proc sql;
select libname, memname, name, type, format, label
from dictionary.columns
where (libname = 'SASHELP' and memname = 'PRDSALE');
quit;

title 'PROC PRINT uses SASHELP.VCOLUMN';
proc print data=sashelp.vcolumn noobs;
where (libname = 'SASHELP' and memname = 'PRDSALE');
var libname memname name type format label;
run;

title;
[/pre]
Contributor
Posts: 47

Re: Proc FREQ - make robust crosstab with different number of vars

Thank you. I'm not familiar with those functions but will research!
Trusted Advisor
Posts: 1,409

Re: Proc FREQ - make robust crosstab with different number of vars

You might also be able to use automatic variables as in

proc freq data=SASHELP.CLASS;
table _numeric_;
run;
Ask a Question
Discussion stats
  • 3 replies
  • 209 views
  • 0 likes
  • 3 in conversation