Hi,
I am writing a format statement and have 'N/A' as a variable that I would like exclude from the crosstabs I am running. Is their a way to write that into my format statement? Thanks
The format statement just assigns formats.
To exclude variables, either don't include them in statements (eg that define tables in tabulate or freq), or drop them from datasets using the drop statement or dataset option.
PS for detailed help, post your code (see https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce)
value $Used_a_recommendation 'Yes' = 'Yes'
'No' = 'No'
'N/A' = 'N/A';
This is my code and I want to remove the N/A so that when I crosstabs it does not show up
So we're not talking about removing a variable, but removing a value!
If you want to exclude certain values, keep them out of the input to the procedure by using a where= dataset option on the input dataset.
Your format does not make sense at all, as it just replaces values with identical values. What were you trying to accomplish with it?
It is part of my larger format statement. I was formatting and running a crosstabs from the format, so I needed that variable in the format to crosstabs against even though I did not want to change any of the values.
I am just trying to create a chart based of the formatted variables and remove the 'N/A' as it is not needed for my graph.
Your solution would be on my import statement to write a where statement that excludes all the 'N/A's of that specific variable?
Do you have an example of what that would look like? Thanks
Please post your code of the tabulation/chart procedure.
proc freq data = mylib.a;
tables Used_a_recommendation*Race /list missing;
format Used_a_recommendation $Used_a_recommendation. Race $Race.;
title Table 8. Used a Recommendation crosstabs by Race;
run;
proc freq data = mylib.a (where=(Used_a_recommendation ne 'N/A'));
tables Used_a_recommendation*Race /list missing;
format Used_a_recommendation $Used_a_recommendation. Race $Race.;
title Table 8. Used a Recommendation crosstabs by Race;
run;
That worked perfectly. Thank you!
If
I could have given you the solution in the first answer. See Maxim 42.
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.
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.