03-08-2018 09:02 AM
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
03-08-2018 09:10 AM
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.
03-08-2018 09:11 AM
PS for detailed help, post your code (see https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce)
03-08-2018 09:21 AM
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
03-08-2018 09:27 AM
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?
03-08-2018 09:33 AM
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
03-08-2018 09:36 AM
03-08-2018 09:38 AM
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;
03-08-2018 10:09 AM
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;
03-08-2018 10:18 AM
I could have given you the solution in the first answer. See Maxim 42.