BookmarkSubscribeRSS Feed
GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

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

10 REPLIES 10
Kurt_Bremser
Super User

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.

GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

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

Kurt_Bremser
Super User

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?

 

 

GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

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

GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

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;

Kurt_Bremser
Super User
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;
GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

That worked perfectly. Thank you!

Kurt_Bremser
Super User

If

  • you had posted the code in your initial post
  • stated that you did not want the value 'N/A' of variable Used_a_recommendation in your frequeny table

I could have given you the solution in the first answer. See Maxim 42.

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

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
  • 10 replies
  • 641 views
  • 0 likes
  • 2 in conversation