Learning SAS? Welcome to the exclusive online community for all SAS learners.

Supressing results in SAS Studio

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Supressing results in SAS Studio

[ Edited ]

When I run tables (i.e. PROC FREQ),  by another variable (e.g. BY gender) we get a table for those cases that have missing data on the BY variable (and also tables for those cases that do not have missing data, which we are interested in). Is there any way to suppress the tables output with an additional line of code so that cases with missing data on the BY variable are not displayed?

 

proc sort; by GENDER;

proc freq; tables SMOKING; by GENDER;

 

And a smaller issue, when we run graphing code to get one graph, we get two identical graphs in the results. Not sure why, but wondering if there is code to suppress this feature. 

 

proc gchart; vbar BIO_SEX SMOKING / Discrete type=PCT width=30;

 

 


Accepted Solutions
Solution
‎04-26-2017 04:36 PM
Super User
Super User
Posts: 7,401

Re: Supressing results in SAS Studio

Have you tried (and I have no access to SAS as not at work) adding a where clause to remove missing values from the by group, that would be my first guess:

proc freq data=<your dataset>;
  tables smoking;
  by gender;
where gender ne ""; run;

As for the rest of it, standards such as Good Coding Practice across all languages (in fact across industries) are there to make programming more open and accesible to everyone, for instance by making code simple and easy to read.  On these (and most) forums you will see how communication can be greatly increased by following some guidances.  

View solution in original post


All Replies
Super User
Super User
Posts: 7,401

Re: Supressing results in SAS Studio

The SAS docs shows how to handle missing values:

https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_freq_sect01...

 

As your learning courses, tip one: Programs should be easy to read.  This is vitally important if your teaching!!

PROC SORT; BY gender;

PROC FREQ; TABLES smoking; BY gender;

 

Should look like:

proc sort data=<your dataset>;
  by gender;
run;
proc freq data=<your dataset>;
  tables smoking;
  by gender;
run;

You will notice it is not all in capitals, new line for each command, blocks are finished (runSmiley Wink dataset is specified.  These all make your code far more readable, and personally, if I look at someones code say in an interview I would make my first decisions on whether the code is readable.

As for your question:

PROC GCHART; VBAR BIO_SEX OLDER4GRADE / Discrete type=PCT Width=30;

I can't tell from that really what it is doing, however for many years now, sgplot, Graph template language and such like have been around.  They are far more up to date, and have more functionality, recommended to move to that.

New Contributor
Posts: 3

Re: Supressing results in SAS Studio

[ Edited ]

Thank you for the link. From the examples and statement that "PROC FREQ treats missing BY variable values like any other BY variable value. The missing values form a separate BY group." it seems there may not be a simple way to suppress this portion of the output.

 

 

 

Solution
‎04-26-2017 04:36 PM
Super User
Super User
Posts: 7,401

Re: Supressing results in SAS Studio

Have you tried (and I have no access to SAS as not at work) adding a where clause to remove missing values from the by group, that would be my first guess:

proc freq data=<your dataset>;
  tables smoking;
  by gender;
where gender ne ""; run;

As for the rest of it, standards such as Good Coding Practice across all languages (in fact across industries) are there to make programming more open and accesible to everyone, for instance by making code simple and easy to read.  On these (and most) forums you will see how communication can be greatly increased by following some guidances.  

New Contributor
Posts: 3

Re: Supressing results in SAS Studio

Thank you for your time. That seems to have worked.

 

I don't debate on-line, but my e-mail is very easy find. 

Super User
Posts: 10,490

Re: Supressing results in SAS Studio

Without data it is extremely hard to diagnose graphics procedures.

 

One thing I see as a potential issue the lack of an explicit data set reference for the proc. It may be the set you are plotting is not the one you think you are as the procedure is going to attempt to use the LAST created data set.

 

You may also want to consider moving to Proc Sgplot instead of Gchart. The statistical graphics procedures are part of base SAS where the traditional deviced based procedures, such as Gchart and Gplot, are not. In the free for learning SAS University Edition the Graph procedures are not available at all but Sgplot, Sgpanel etc. are.

 

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 226 views
  • 1 like
  • 3 in conversation