Hello:
I would like to count the group frequency of the two columns "Analysis" and "Product" in test1 table below. Please advice how to approach. Thanks.
data test1;
infile datalines dlm='|';
input name : $20. Analysis : $100. Product : $100.;
datalines;
Ali| Cleft Lip +/- Palate| LABETOLOL|
Ali| Cleft Lip +/- Palate| ATENOLOL|
Ali| VSDs (Excludes VSDavc)| ATENOLOL|
Ali| VSDs (Excludes VSDavc)| FLUCONAZOLE|
Carol| Choanal Atresia| LEVOTHYROXINE SODIUM|
Carol| Cleft Lip +/- Palate| ATENOLOL|
Carol| Intestinal Atresia/Stenosis| EPHEDRA|
Malyn| TGA +/- DORV| ALBUTEROL SULFATE|
Malyn| TOF +/- PA, DORV -TGA| BUTALBITAL|
Malyn| Esoph Atresia +/- TEF| FLONASE|
;
proc sort data=test1; by analysis; run;
The result I am looking for is:
Analysis Count
Cleft Lip +/- Palate 3
VSDs (Excludes VSDavc) 2
Choanal Atresia 1
Intestinal Atresia/Stenosis 1
TGA +/- DORV 1
TOF +/- PA, DORV -TGA 1
Esoph Atresia +/- TEF 1
Product
LABETOLOL 1
ATENOLOL 2
FLUCONAZOLE 1
LEVOTHYROXINE SODIUM 1
EPHEDRA 1
ALBUTEROL SULFATE 1
BUTALBITAL 1
FLONASE
Please post example code in a code box opened with either the {I} or running man icon.
Please.
Do you really want a record of data with no values (the blank dataline)?
Is the ORDER of the appearance important? If so you might specify the rules.
If I wanted the output in descending order of frequency I would start with
proc freq data=test1 order=freq; tables analysis product /nocum nopercent; run;
Please post example code in a code box opened with either the {I} or running man icon.
Please.
Do you really want a record of data with no values (the blank dataline)?
Is the ORDER of the appearance important? If so you might specify the rules.
If I wanted the output in descending order of frequency I would start with
proc freq data=test1 order=freq; tables analysis product /nocum nopercent; run;
I don't know how to post example code in a code box opened with either the {I} or running man icon. I add { } before and after my codes. Does it help?
How to generate a permeant SAS dataset instead of in the "result viewer"? Is there a way to output in one table? Thanks.
You should learn how. It makes it easier on us to help you.
And please try reading the documentation BEFORE asking questions.
The first example in PROC FREQ:
@ybz12003 wrote:
I don't know how to post example code in a code box opened with either the {I} or running man icon. I add { } before and after my codes. Does it help?
How to generate a permeant SAS dataset instead of in the "result viewer"? Is there a way to output in one table? Thanks.
@ybz12003 wrote:
How to generate a permeant SAS dataset instead of in the "result viewer"? Is there a way to output in one table? Thanks.
Proc freq can create one output data set per tables request which would be for one variable. You could append two data sets to get one though.
HOW would you use the single data set with both variables summarized? There can be significant issues in what needs to be done to use such a summarized set depending on exact usage.
You can use ODS to get both into one table, demoed below
Thanks for all your great suggestion.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.