Hello - I would like to understand how to solve the below using select and subselect query
proc sql ;
title '64 and younger & 469';
select count(desy_sort_key) from etl.inp_claims_lds2013_2016 where
Age_Range='64 and younger' and clm_drg_cd='469';
quit;
Sounds like a good problem for PROC FREQ.
proc freq data=etl.inp_claims.... ;
where clm_drg_cd='469';
table age_range*desy_sort_key;
run;
@fpascal wrote:
Hello - I would like to understand how to solve the below using select and subselect query
- count all desy_sort_keys where clm_drg_cd = '469'
- count all desy_sort_keys where clm_drg_cd = '469' and age_range = '64 and younger'
- select the count from item 2 and divide it by item 1 creating a percentage in the format of 99.9%
proc sql ;
title '64 and younger & 469';
select count(desy_sort_key) from etl.inp_claims_lds2013_2016 where
Age_Range='64 and younger' and clm_drg_cd='469';
quit;
Sounds like a good problem for PROC FREQ.
proc freq data=etl.inp_claims.... ;
where clm_drg_cd='469';
table age_range*desy_sort_key;
run;
@fpascal wrote:
Hello - I would like to understand how to solve the below using select and subselect query
- count all desy_sort_keys where clm_drg_cd = '469'
- count all desy_sort_keys where clm_drg_cd = '469' and age_range = '64 and younger'
- select the count from item 2 and divide it by item 1 creating a percentage in the format of 99.9%
proc sql ;
title '64 and younger & 469';
select count(desy_sort_key) from etl.inp_claims_lds2013_2016 where
Age_Range='64 and younger' and clm_drg_cd='469';
quit;
@fpascal wrote:
Reeza - my data set has only 74K obs. For the above solution it is still running. Is that normal?
No.
Did you terminate it correctly with a RUN;?
Reeza
The output finally came back - its attached. The problem is I wanted a count(#) for each age group by counting desy_sort_key. How would I modify the proc frequency code?
That's what it did, you just happen to have a lot of 0's.
Format is a different issue - all the values you need are there. I would suggest creating an output table then instead or a listed table. You should review the options available for PROC FREQ in the documentation.
See the example below
proc freq data=sashelp.cars noprint;
table origin*cylinders / out=summary outpct;
run;
@fpascal wrote:
Reeza
This is the table format I was looking for
Count(Desy_sort_key)
Age Range
64 and younger 99.9% (percentage of the total count of desy_sort_key for 469)
70 to 74 99.9% (percentage of the total count of desy_sort_key for 469)
75 to 79 99.9% (percentage of the total count of desy_sort_key for 469)
80 to 84 99.9% (percentage of the total count of desy_sort_key for 469)
85 and older 99.9% (percentage of the total count of desy_sort_key for 469)
Note that I can't see your data so I'm making assumptions. It's possible they're wrong, so feel free to test out different options as needed and play around with the different table structures. See the SAS PROC FREQ documentation for examples and the list of options available.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.