- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 11-29-2023 12:37 AM
(810 views)
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.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here is what I did.
ods exclude all;
proc freq data=MaTab;
table Sexe *(a b c)/ nopercent nofreq nocol out=tab1 ;
run;
data tab1;
set tab1;
variable=compress("Sexe","'n'");;
Modalite=Sexe;
run;
From here, I want to create my table for the "Sex" variable.
I will do the same method for age. Then I'll concatenate to get my "Want" table.
My difficulty is to create the table "tab1_sum" which will look like this :
data tab1_sum;
input Variable $ Modalite $ a $ b $ c $ ;
datalines;
Sexe F sum_of_pourcent(fort1,fort2,fort3) sum_of_pourcent(fort1,fort2,fort3) sum_of_pourcent(fort1,fort2,fort3)
Sexe H sum_of_pourcent(fort1,fort2,fort3) sum_of_pourcent(fort1,fort2,fort3) sum_of_pourcent(fort1,fort2,fort3)
;
run;
Then this table "tab1_sum" will be concatenate for each variable in order to have my final table (want).
Can someone help me please.
THANKS
Gick
ods exclude all;
proc freq data=MaTab;
table Sexe *(a b c)/ nopercent nofreq nocol out=tab1 ;
run;
data tab1;
set tab1;
variable=compress("Sexe","'n'");;
Modalite=Sexe;
run;
From here, I want to create my table for the "Sex" variable.
I will do the same method for age. Then I'll concatenate to get my "Want" table.
My difficulty is to create the table "tab1_sum" which will look like this :
data tab1_sum;
input Variable $ Modalite $ a $ b $ c $ ;
datalines;
Sexe F sum_of_pourcent(fort1,fort2,fort3) sum_of_pourcent(fort1,fort2,fort3) sum_of_pourcent(fort1,fort2,fort3)
Sexe H sum_of_pourcent(fort1,fort2,fort3) sum_of_pourcent(fort1,fort2,fort3) sum_of_pourcent(fort1,fort2,fort3)
;
run;
Then this table "tab1_sum" will be concatenate for each variable in order to have my final table (want).
Can someone help me please.
THANKS
Gick
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.