Hi,
I am familiar with this issue but cant fix it. I'm getting the following error from pro tabulate:
WARNING: A class variable is crossed with itself in the table statement at line 867. This may cause unpredictable results.
WARNING: A class variable is crossed with itself in the table statement at line 867. This may cause unpredictable results.
NOTE: There were 5361 observations read from the data set WORK.AGE.
NOTE: PROCEDURE TABULATE used (Total process time):
real time 1.16 seconds
I know this is as a result of a cross tab of the same variable however, I do not know how to resolve the issue in this code (FYI: I found the code online and modified it).
This is a part of the code:
%macro do_freq_gender;
%do j=1 %to &numvars;
proc tabulate data=gender;
class gender &&var_&j. ;
table (&&var_&j. all),
(gender all='All') * (N colpctn='% of Col');
format gender sexf.
&&var_&j. &&fmt_&j.;
run;
%end;
%mend;
Any help please. Thanks.
Thank you for the explanation. You are right, the macro is hard-coded. I do not know enough about macro to resolve this problem. Please can you provide more example as to how I can modify the macro program to skip the loop or how I can check (&&var_&j) to remove the variable. Thanks again
@CathyVI wrote:
Thank you for the explanation. You are right, the macro is hard-coded. I do not know enough about macro to resolve this problem. Please can you provide more example as to how I can modify the macro program to skip the loop or how I can check (&&var_&j) to remove the variable. Thanks again
You macro code is using multiple variables that do not appear in the macro definition so it is not easy to address. You would have to include the code used to create all of those macro variables. That would likely be the better place to address things.
Note that Proc Tabulate can contain multiple CLASS, VAR and Table statements. So if this code is supposed to be looping over the same data set multiple times and creating separate tables for each variable then the entire process should be looked at as each time the procedure is called with the same data set your code reloads the data. With moderate to large datasets this could result in considerable times.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.