SAS: PROC MEANS Grouping in Class Variable -


i have following sample data , 'proc means' command.

data have; input measure country $; datalines;  250 uk 800 ireland  500 finland 250 slovakia 3888 slovenia 34 portugal 44 netherlands 4666 austria run; proc print data=have; run; 

the following proc means command prints out listing each country above. how can group of countries (i.e. uk & ireland, slovakia/slovenia central europe) in proc means step, rather adding datastep add 'case when' etc?

proc means data=have sum  maxdec=2 order=freq stackods; var measure; class country; run; 

thanks @ on this. understand there various things can in proc means command (like limit number of countries doing this:

proc means data=have(where=(country not in ('finland', 'uk') 

i'd grouping in proc means command brevity.

thanks.

this easy format proc takes class statement.

simply build format, either code or data; apply format in proc means statement.

proc format lib=work; value $countrygroup "uk"="british isles" "ireland"="british isles" "slovakia","slovenia"="central europe" ; quit;  proc means data=have; class country; var measure; format country $countrygroup.; run; 

it's better have numeric codes country , format whichever set of names needed @ 1 time, particularly capitalization/etc. pretty irritating, works enough here.

the cntlin= option in proc format allows make format dataset, fmtname value statement, start value-to-label, label label. (end=end of range if numeric.) there other options also, documentation goes more detail.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -