SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
unnati
Obsidian | Level 7

 

sas.PNG

 

*** ICT total= sum(drugB DrugC DrugE)

*** Total=sum(DrugA DrugB DrugC drugE) (which I know I can do using output option in data setp)

*** (xx.x)percentage = xx/N

***N= Bign count for each coulnm(N=XXX)

 

Can anyone help me to calculate for ‘ICT Total column’ counts. (5th column)

I need to calculate 5th column count for header which is (N=XXX) and table count which is xx(xx.x).

I am currently doing as follow. But is there any other way to do this instead of doing two proc sql and data set statement.

 

data dataB;

set dataA;

output;

trtp='Total';

output;

run;

 

proc sql;

create table bign as

select count(distinct subjid) as nsize, trtp

from dataB

WHERE TRTP NE ''

GROUP BY TRTP;

quit;

 

 

proc sql;

create table aa as

select sum(nsize) as nsize, 'ICT' as trtp

from bign

where trtp not in ('Total','DrugA');

quit;

 

data bign1;

set bign aa;

run;

 

PROC SORT DATA=BIGN1;BY TRTP;RUN;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
For a report like that I'd be using PROC MEANS. It allows you to calculate measures at different levels and if you use an MLF you can get different group combinations as desired. Then you use PROC REPORT to display the information.

MLF will allow you to calculate the totals at the overall level, as well as just ICT level.

View solution in original post

8 REPLIES 8
Reeza
Super User
For a report like that I'd be using PROC MEANS. It allows you to calculate measures at different levels and if you use an MLF you can get different group combinations as desired. Then you use PROC REPORT to display the information.

MLF will allow you to calculate the totals at the overall level, as well as just ICT level.

unnati
Obsidian | Level 7

Can you please provide sample code for this table.  

Reeza
Super User

Provide sample data and your current code for reporting please. You haven't provided data to work with.


@unnati wrote:

Can you please provide sample code for this table.  


 

unnati
Obsidian | Level 7

I have attached one excel file. please help me with code example.

Reeza
Super User

 

Example 8 in this paper is what you want:

https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/173-2008.pdf

The code is in this file:

https://support.sas.com/rnd/papers/sgf2008/complex_reports.zip

 

I cannot download attachments.

 


@unnati wrote:

I have attached one excel file. please help me with code example.


 

 

ballardw
Super User

Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.

ChrisNZ
Tourmaline | Level 20

@ChrisHemedinger I reckon that this line about MS Office attachments, along with those in @Kurt_Bremser's signature, should be added as part of a list of checkbox prerequisites that must be validated before the Post button is ungrayed, when asking a new question. 

andreas_lds
Jade | Level 19

@ChrisNZ wrote:

@ChrisHemedinger I reckon that this line about MS Office attachments, along with those in @Kurt_Bremser's signature, should be added as part of a list of checkbox prerequisites that must be validated before the Post button is ungrayed, when asking a new question. 


I would like to go one step further: prevent uploading of ms office files at all.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 6551 views
  • 3 likes
  • 5 in conversation