I have the following dataset: What I would like to do is create treatment*type and have frequency (percent)
| ID | Type | treatment |
| 123 | 1 | 1 |
| 343 | 2 | 2 |
| 354 | 1 | 3 |
| 656 | 2 | 3 |
| 446 | 2 | 2 |
| 665 | 2 | 1 |
| 444 | 2 | 1 |
| 665 | 1 | 1 |
| 656 | 1 | 2 |
proc sort data = test; by treatment type; run;
Here is the code I have:
proc freq data = test;
tables treatment*type / out = test2 ;
run;
When I run it i get the output correctly but when i export to another table it doesn't retain important characteristics such as 'Frequency' and 'Col Percent'
After spending 2 minutes reading the documentation, I now know that adding option OUTPCT to the OUTPUT statement does what you want.
Why come here and open a question without reading the documentation first?
> it doesn't retain important characteristics such as 'Frequency' and 'Col Percent'
It sure does.
proc freq data=SASHELP.CLASS; tables SEX*AGE /out=T; run;
oops COLPCT. Sorry. Let me look.
After spending 2 minutes reading the documentation, I now know that adding option OUTPCT to the OUTPUT statement does what you want.
Why come here and open a question without reading the documentation first?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.