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

Hi! I am trying to recreate a current table I have into the format that proc tabulate creates, but it's not working out correctly. I'm not sure where I am currently going wrong.

 

I have an outputted table that looks like this:

datetaking_medscount
1/10500
1/11100
1/2046
1/2194
1/30455
1/3112
1/40224
1/4181

 

When I do proc_tabulate, I get the following table:

A_Halps_0-1635878979743.png

 

It should look like this though:

A_Halps_1-1635879879681.png

 

 

Here is my code:

proc sql;
create table meds as
select distinct date, taking_meds, count(*) as count
from (select * from t_meds where date ne "")
group by date, taking_meds;
quit;


proc tabulate data = meds;
class date taking_meds;
tables date, taking_meds* (N rowpctn) all;
run;

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Amethyst | Level 16

you need to specify FREQuency:

data  meds;
input date $ taking_meds count;
cards;
1/1	0	500
1/1	1	100
1/2	0	46
1/2	1	94
1/3	0	455
1/3	1	12
1/4	0	224
1/4	1	81
;
run;

proc tabulate data = meds;
  class date taking_meds;
  FREQ count;
  tables date, taking_meds * (N rowpctn) all*N;
run;

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

2 REPLIES 2
yabwon
Amethyst | Level 16

you need to specify FREQuency:

data  meds;
input date $ taking_meds count;
cards;
1/1	0	500
1/1	1	100
1/2	0	46
1/2	1	94
1/3	0	455
1/3	1	12
1/4	0	224
1/4	1	81
;
run;

proc tabulate data = meds;
  class date taking_meds;
  FREQ count;
  tables date, taking_meds * (N rowpctn) all*N;
run;

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



A_Halps
Obsidian | Level 7
Thank you!!!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 910 views
  • 1 like
  • 2 in conversation