data MaTab;
input Sexe $ age $ a $ b $ c $ ;
datalines;
F [2-10] fort1 fort2 fort1
H [10-20] fort2 fort1 fort3
F [2-10] fort1 fort1 fort1
F [30-40] fort3 fort1 fort2
H [10-20] fort2 fort1 fort1
H [30-40] fort2 fort3 fort2
H [30-40] fort1 fort3 fort1
F [2-10] fort3 fort3 fort3
;
run;
/*I would like to have a table like:*/
data want;
input Variable $ Mod $ a $ b $ c $ ;
datalines;
Sexe F somme(fort1,fort2,fort3) somme(fort1,fort2,fort3) somme(fort1,fort2,fort3)
Sexe H somme(fort1,fort2,fort3) somme(fort1,fort2,fort3) somme(fort1,fort2,fort3)
age [2-10] somme(fort1,fort2,fort3) somme(fort1,fort2,fort3) somme(fort1,fort2,fort3)
age [10-20] somme(fort1,fort2,fort3) somme(fort1,fort2,fort3) somme(fort1,fort2,fort3)
age [30-40] somme(fort1,fort2,fort3) somme(fort1,fort2,fort3) somme(fort1,fort2,fort3)
;
run;
Hi,
Note that in the final "Want" table, the sum of the strong is the percentage sum of the crossing sex and a, sex and b, sex and c. I actually get the percentage to create this table. Same approach with age.
Can someone suggest an approach or a program allowing me to have this table (want).
Thanks for your help.
Best regards,
Gick.
You don't show any numbers in your expected output so it is impossible to tell what "percentage sum" you want to calculate.
Also it looks like you have unique combinations for A, B and C so the counts of any frequency tables are going to be 1 in every combination so I am not sure what you intended to calculate.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.