- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I hope this is a simple question. I have a program that includes a proc format and a proc summary. When I run the proc summary, the values in the class statement column (cos) come out character but I want them to be numeric. I want cos to be numeric. Can I do that?
** Here is the program **
proc format ;
value cos (multilabel)
1-62 = 999
1-57 = 888
58-62 = 102
;
run;
proc import
datafile= "T:\gxs03\Misc\exampledata.csv"
dbms=csv
out=example
replace;
run;
proc summary data=example nway ;
class cos / mlf ;
format cos cos.;
var count pop;
output out=exampleregion sum=;
run;
** Here are the data **
| cos | count | pop |
| 1 | 35000 | 983 |
| 2 | 746 | 5 |
| 58 | 462158 | 49773 |
| 3 | 9534 | 319 |
| 59 | 760449 | 44365 |
** Here is the output**
| cos | _TYPE_ | _FREQ_ | count | pop |
| 102 | 1 | 2 | 1222607 | 94138 |
| 888 | 1 | 3 | 45280 | 1307 |
| 999 | 1 | 5 | 1267887 | 95445 |
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Using MultiLabel formats in PROC SUMMARY force the variable in the OUTPUT data set to be character.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Using MultiLabel formats in PROC SUMMARY force the variable in the OUTPUT data set to be character.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
PaigeMiller, thanks, that's good to know. But the problem is that cos divides the groups into three, and one overlaps with the other two.
Cos is counties. 1-57 are New York State outside of New York City. 58-62 are New York City. And 1-62 is New York State, which overlaps with the other two.
proc format ;
value cos (multilabel)
1-62 = 999
1-57 = 888
58-62 = 102
;
run;
So I kind of have to use these three overlapping groups. 😞
But good to know "multilable" makes them character.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I don't understand the issue here. You have chosen to group the data 3 ways, and now it sounds like this is not what you want to do? Please explain in more detail.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@geneshackman wrote:
I mean, I want cos in the output data set, generated by proc summary, to be numeric.
Can't be done with multi-label formats.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Just change it to numeric by adding another step.
data want;
length cos 8;
set exampleregion (rename=(cos=string));
cos = input(string,32.);
drop string;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In this case, the value of the format is unique and just digits, so it can be converted to numeric with an extra step. In other cases, the value of the format is not just digits, and cannot be easily converted (if it can be converted at all) to numeric.
Paige Miller