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:
date | taking_meds | count |
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 |
When I do proc_tabulate, I get the following table:
It should look like this though:
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!
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
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
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: