BookmarkSubscribeRSS Feed
anjgupta
Calcite | Level 5
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.
3 REPLIES 3
Cynthia_sas
Diamond | Level 26
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]
anjgupta
Calcite | Level 5
Thank you. I'm not familiar with those functions but will research!
ChrisNZ
Tourmaline | Level 20
You might also be able to use automatic variables as in

proc freq data=SASHELP.CLASS;
table _numeric_;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1427 views
  • 0 likes
  • 3 in conversation