BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sam369
Obsidian | Level 7

Hi Experts,

I have a question on proc tabulate.the data look like

data test;

do grp=1 to 6;

  do flg='Yes','No';

   do sec='dsfsa', 'fdafa', 'afafa';

   output;

  end;

end;

end;

run;

proc tabulate data=test;

class grp flg sec;

table grp *FLG ,sec='section'

  * (n='n' * f=10. COLPCTN='%' * f=7.2 )/ misstext='0' rts=40;

run;

my o/p:

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ†

‚                                      ‚                        section                         ‚

‚                                      ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰

‚                                      ‚      afafa       ‚      dsfsa       ‚      fdafa       ‚

‚                                      ‡ƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒ‰

‚                                      ‚    n     ‚   %   ‚    n     ‚   %   ‚    n     ‚   %   ‚

‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚grp               ‚flg                ‚          ‚       ‚          ‚       ‚          ‚       ‚

‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰          ‚       ‚          ‚       ‚          ‚       ‚

‚1                 ‚No                 ‚         1‚   8.33‚         1‚   8.33‚         1‚   8.33‚

‚                  ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚                  ‚Yes                ‚         1‚   8.33‚         1‚   8.33‚         1‚   8.33‚

‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚2                 ‚No                 ‚         1‚   8.33‚         1‚   8.33‚         1‚   8.33‚

‚                  ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚                  ‚Yes                ‚         1‚   8.33‚         1‚   8.33‚         1‚   8.33‚

‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚3                 ‚No                 ‚         1‚   8.33‚         1‚   8.33‚         1‚   8.33‚

‚                  ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚                  ‚Yes                ‚         1‚   8.33‚         1‚   8.33‚         1‚   8.33‚

‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚4                 ‚No                 ‚         1‚   8.33‚         1‚   8.33‚         1‚   8.33‚

‚                  ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚                  ‚Yes                ‚         1‚   8.33‚         1‚   8.33‚         1‚   8.33‚

Šƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒŒ

but my desired o/p is

„ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ†

‚                                      ‚                        section                         ‚

‚                                      ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰

‚                                      ‚      afafa       ‚      dsfsa       ‚      fdafa       ‚

‚                                      ‡ƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒ‰

‚                                      ‚    n     ‚   %   ‚    n     ‚   %   ‚    n     ‚   %   ‚

‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚grp               ‚flg                ‚          ‚       ‚          ‚       ‚          ‚       ‚

‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰          ‚       ‚          ‚       ‚          ‚       ‚

‚1                 ‚No                 ‚         1‚   50.00‚         1‚   50.00‚         1‚   50.00‚

‚                  ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚                  ‚Yes                ‚         1‚   50.00‚         1‚   50.00‚         1‚   50.00‚

‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚2                 ‚No                 ‚         1‚   50.00‚         1‚   50.00‚         1‚   50.00‚

‚                  ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚                  ‚Yes                ‚         1‚   50.00‚         1‚   50.00‚         1‚   50.00‚

‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚3                 ‚No                 ‚         1‚   50.00‚         1‚   50.00‚         1‚   50.00‚

‚                  ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚                  ‚Yes                ‚         1‚   50.00‚         1‚   50.00‚         1‚   50.00‚

‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚4                 ‚No                 ‚         1‚   50.00‚         1‚   50.00‚         1‚   50.00‚

‚                  ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰

‚                  ‚Yes                ‚         1‚   50.00‚         1‚   50.00‚         1‚   50.00‚

Šƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒŒ

can i produce this kid of output by using proc report?

Thanks

Sam

1 ACCEPTED SOLUTION

Accepted Solutions
AncaTilea
Pyrite | Level 9

Hi.

Your code is very close to accomplist what you wanted:

proc tabulate data=test;

class grp flg sec;

table grp *FLG ,sec='section'

  * (n='n' * f=10. pctn<flg>='%' * f=7.2 )/ misstext='0' rts=40;

run;

Good luck!

Anca.

View solution in original post

4 REPLIES 4
AncaTilea
Pyrite | Level 9

Hi.

Your code is very close to accomplist what you wanted:

proc tabulate data=test;

class grp flg sec;

table grp *FLG ,sec='section'

  * (n='n' * f=10. pctn<flg>='%' * f=7.2 )/ misstext='0' rts=40;

run;

Good luck!

Anca.

sam369
Obsidian | Level 7


Hi Anca,

Thank you !!! I Tried  PCTN but i used wrong variable , i am applying on grp!!!! . Now i  got what i want.

Is the same table can we generate using proc report. because i need to add another variable like sec(afafa,dsfsa ‚fdafa) , that varible name is mflag(Yes,NO). i am unable to do it in one table by using proc tabluate,

my final o/p with new added variable is shown like this

                                                                            section                                                        mflag

grp                  flg                               afafa              dsfsa           fdafa                                  Yes                   No

                                                        n         %          n        %       n         %                         n         %          n        %        

1                    No                            XX        XX        XX       XX       XX      XX                       XX        XX         XX       XX

                      Yes                          XX        XX        XX       XX       XX      XX                       XX        XX         XX       XX

I below is the code i am using but it throws a error in log:

proc tabulate data=subgrps;

class grp flg sec mflag;

table grp *flg ,sec=’Section’

* (n='n' * f=10. PCTN<FLG>='%' * f=7.2 ), mflag=’Mflag’

* (n='n' * f=10. PCTN<FLG>='%' * f=7.2 )/ misstext='0' rts=40;

run;

Thanks

Sam

AncaTilea
Pyrite | Level 9

Hi. glad it worked.

You need to remove the comma before the mflag = "Mflag" * (....);

Using this data:

data test;

do grp=1 to 4;

  do flg='Yes','No';

   do mflag  = "Yes", "No";

   do sec='dsfsa', 'fdafa', 'afafa';

   output;

  end;

  end;

end;

end;

run;

proc tabulate data=test;

class grp flg sec mflag;

table grp *flg ,

  sec="Section" * (n="n" * f=10. PCTN<FLG>="%" * f=7.2 )

  mflag="Mflag" * (n="n" * f=10. PCTN<FLG>="%" * f=7.2 )

  / misstext="0" rts=40;

run;

Good luck.

Anca.

sam369
Obsidian | Level 7

Thank you so much  Anca. It worked!!!!! That is what exactly i want.

Regards

Sam.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 836 views
  • 2 likes
  • 2 in conversation