Help using Base SAS procedures

Formats and tabulate

Reply
N/A
Posts: 0

Formats and tabulate

Hello everyone:

I have a trouble when dealing with format.
Here is a example:

data trial;
input id age grade;
cards;
1 23 1
2 39 1
3 45 4
4 56 10
5 67 2
6 78 11
7 89 12
;
proc format;
value agefmt 0-<20=A
21-<30=B
31-<40=C
41-<50=D
51-<60=E
61-<70=F
71-<80=G
81-<90=H;
value grafmt 1-6=J
7-9=S
10-12=H;
run;

proc tabulate data=trial;
class age grade;
tables age,grade;
format age agefmt. grade grafmt. ;
run;

I would like to produce a table, which row and column are composed by values of format agefmt and grafmt, but this

program ignores missing values for format.
How can I produce table like this :
J S H
A
B
C
D
E
F
G
H

Thank you in advance. Smiley Happy
Super Contributor
Super Contributor
Posts: 3,174

Re: Formats and tabulate

Posted in reply to deleted_user
You will want to review this post, before re-posting your code:

http://support.sas.com/forums/thread.jspa?messageID=27609


Scott Barry
SBBWorks, Inc.
Super User
Posts: 10,023

Re: Formats and tabulate

Posted in reply to deleted_user
Hi. you do not say something about your error .
and what do your log look like?

proc format;
value agefmt 0-<20= ??????? ; you also give nothing information.
N/A
Posts: 0

Re: Formats and tabulate

Posted in reply to deleted_user
sorry, I haven't notice that there is a limit in line of one topic.

I need a report which column and row are consisted by all values defined in format procedure previously, but there are some missing values for several values of format, so in report generated by tabulate procedure or freq procedure, some columns and rows I demanded will be missing. How can I get the result I need?

Thank you in advance. Smiley Happy
Respected Advisor
Posts: 4,173

Re: Formats and tabulate

Posted in reply to deleted_user
The issue is not a line limitation but that certain character combinations are interpreted as HTML code instead of content (that's the link Scott pointed you to).

As for your question.
I have to guess a bit as not your full post made it to this forum but you might be interested in investigating the options "missing" or "CLASSDATA=" for Proc Tabulate ( http://support.sas.com/onlinedoc/913/getDoc/en/proc.hlp/a002473736.htm#a003069171 )

HTH
Patrick
SAS Super FREQ
Posts: 8,864

Re: Formats and tabulate

Posted in reply to deleted_user
Your ability to post code will be greatly enhanced if you read the forum posting that Scott referenced. Any code with < or > must be treated specially for posting so it does not conflict with the HTML used to maintain the forum. That's what Scott's article talks about -- how to protect those special characters and how to post code snippets.

In addition, these previous forum postings and Tech Support notes discuss the use of PRELOADFMT with PROC TABULATE to account for the appearance of CLASS variables in the table, even if the values themselves do not appear in the data.

http://support.sas.com/forums/thread.jspa?messageID=19957䷵
http://support.sas.com/forums/thread.jspa?messageID=14459㡻
http://support.sas.com/forums/thread.jspa?messageID=4872ገ
http://support.sas.com/forums/thread.jspa?messageID=17685䔕
http://support.sas.com/kb/25/101.html
http://support.sas.com/kb/25/400.html
http://support.sas.com/kb/25/403.html
http://support.sas.com/kb/23/846.html

cynthia
N/A
Posts: 0

Re: Formats and tabulate

Posted in reply to Cynthia_sas
Thank you, Cynthia, Krasharp and everyone. SAS and this forum are really fresh for me, and the history topics are quite useful.
Super User
Posts: 10,023

Re: Formats and tabulate

Posted in reply to deleted_user
[pre]
proc freq data=sashelp.class;
tables name /missing;
format name fmt.;
run;
[/pre]

[pre]
proc tabulate data=sashelp.class;
class name /preloadfmt;
table name/printmiss;
format name fmt.;
run;
[/pre]


Ksharp Message was edited by: Ksharp
Ask a Question
Discussion stats
  • 7 replies
  • 310 views
  • 0 likes
  • 5 in conversation