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
Onyx | Level 15

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
Onyx | Level 15

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!!!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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
  • 2 replies
  • 475 views
  • 1 like
  • 2 in conversation