Reputation: 11
This question have probably a very easy answer.
I have 21 class variables , one for each year 2000 to 2021 and want to show percentage for each group (two levels)
proc tabulate data=grundkom;
class kommuntxt2000-kommuntxt2021 grupp/missing;
table grupp='',(kommuntxt2000-kommuntxt2021)*N;
run;
This works, but give a very wide table to read.
I want the 21 variables (years) to be under each other (they all have the same levels) Landsbygdskommun Landsbygdskommun med besöksnäring Lågpendlingskommun nära större stad Mindre stad/tätort Pendlingskommun nära mindre tätort Pendlingskommun nära storstad Pendlingskommun nära större stad Storstäder Större stad
Example for first 2 years:
Tried only doing it straight forward in "proc tabulate", but maybe you need to transform data in some way.
Upvotes: 0
Views: 45
Reputation: 51621
Move the YEAR out of the metadata and into the data.
data grundkom_tall;
set grundkom;
array k [2000:2021] kommuntxt2000-kommuntxt2021 ;
do year = 2000 to 2021;
kommuntxt = k[year];
output;
end;
drop kommuntxt2000-kommuntxt2021;
run;
proc tabulate data=grundkom_tall;
class year kommuntxt grupp/missing;
table grupp=''*year,kommuntxt*N;
run;
Upvotes: 2