Hi to all,
we've got a problem on how to render a set of tabulates...let me explain: we've got to plot a table which shows, for city and year, the percentage of family with one person over the total of the families. We've than applied the proc summary, and got in this way the correct percentage .
However, we need to apply a format to the cities, which groups the city for "association": we have this format which says for each city the correct association and:
- with start/end value of 999999 we point to the "All" association (in order to group them and show them in this kind of table...never let tabulate sum a percentage)
- with an entry of "No association" for the cities which don't apply to any format (it's a format with the Other option: no start or end).
This seems to work pretty well, except for the order on which the class variables are printed ...unfortunately, the "No association" label is ALWAYS after the "All" label...and we are struggling to find a way to order in the other way! But even saying that order has to be "data" in the proc tabulate, and seeing that last observations are the total one...it doesn't work .
Share your code by pasting it into another REPLY with this post.
If you intend to chart/report values differently than in alphabetic-order, you will need to construct a FORMAT (numeric most likely) and assign representative values to achieve your desired order/sequence.
I'm not entirely sure I understand what you want, but this note describes how to use PRELOADFMT and ORDER=DATA to ensure that you get the order you want with multi-label formats. http://support.sas.com/kb/12/904.html
The simplified code below shows how to use TABULATE to get the formats in the order you want, with regular formats and with multilabel formats. The PRELOADFMT option loads the format as it is stored and the NOTSORTED in PROC FORMAT ensures that the format is stored in the order you defined. Either with or without multi-label formats, you can get the CLASS variables in the order you want.
Hi to all,
thank you for your answer! I've found to be part of the problem the use of the preloadfmt, and I've solved 90% of the problems found.
Unfortunately, I cannot post the code...it's too much complicated and confused by macro code, and it would be just an headache for each one who would try to help me .
Cynthia, your code looks quite interesting, but I've to ask something about the "notsorted" option: actually, we've got a program running each night which updates the formats.
However, we update the format using the cntlin option: we have prepared a table (downloaded from a SQL Server) which contains the minimum fields for creating a format...which field should I had for the "notsorted"?
An easy way to figure out what variables and values are needed for a CNTLIN data set is to look at a CNTLOUT data for similar formats/informats. I believe the answer to your question is to include S in the HLO variable.
T S L
N T A
O A A E B H
b M R N E L
s E T D L O
1 AGEMLF 11 12 pre-teen SM
2 AGEMLF 13 19 teenager SM
3 AGEMLF 11 14 non-driver SM
4 AGEMLF 15 HIGH driver SMH
5 REGAGE 11 12 Z S
6 REGAGE 13 14 A S
7 REGAGE 15 HIGH H SH
Hi to all,
in the end we solved our problem by changing our format and avoiding using the "other" option in the formats...but still, I'd like to understand what I'm missing here.
Consider this sample code:
I don't believe you can use OTHER for this situation, given that your data are structured the way they are. For other reports, I have done something like this:
value $first (notsorted) '1' = 'First'
2-998 = 'None'
other = 'Total';
But, this assumes that you know, from the structure of the data that only the 999 obs are left and that you will -never- have a number greater than 999 being used with this format.
thank you very much for your answer! Finally, everything is explained .
This was of course a simplified problem: the real problem was that the format is dynamically updated every night, and so we are sure that there aren't any cities with code '999999' (our total format), but...maybe tonight the city 199 is inside a format, tomorrow it's outside any category and then it should fall back to the "other" category
As we've got a complete list of the cities, we've done a simple code which associates each code of a city who doesn't fall into a format created by the user into a new "None" format, and we have created the format notsorted, ordered as we wanted. This is unfortunately less elegant than using the other format (which I found brilliant, until I was asked this particular order...), but it's still the best solution we could find.
Again, thanks for unveiling the problem