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
SAS Super FREQ
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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 885 views
  • 0 likes
  • 3 in conversation