BookmarkSubscribeRSS Feed
TJ87
Obsidian | Level 7

I would like to efficiently output frequencies, percent, and cumulative time for a number of categorical variables. 

 

My dataset variables include:

ID number

Many variables for genes with the prefix "rs", with three possible categories per variable

Case (1 or 0)

Years of follow-up per case

Death (1 or 0)

 

I would like my final output to look like this for each gene:

 

rs#:                       Cases # (% of total cases):    PYears:   Deaths # (% of total deaths):

Category1

Category2

Category3

 

My program to calculate Years for each gene and category:

 

proc sort data=analytic; by case rs1; run;

PROC MEANS DATA=analytic NWAY noprint;
  VAR Years ;
  by case rs1;
  OUTPUT OUT=survival SUM=PYears;
    RUN;

 

I would be grateful if someone could post a macro to do this efficiently since I have many genes to consider. 

2 REPLIES 2
Astounding
PROC Star

If you have a program that is working for one gene, it's just a hop, skip, and a jump away.  Right now  you are sorting/processing:

 

by case rs1;

 

Instead,  you can process:

 

by gene case rs1;

Reeza
Super User

For pre written macros search lexjansen.com and clinical reports or summary tables. 

You'll find a ton of papers with detailed explanations. 


There's one that's a great reference: Creating Complex Reports by Cynthia Zender. 

 

FYI - as phrased, your question isn't coming across as help me do something I can't do, but can you please do my work? Obviously this is up to people how they respond to questions of this nature.

sas-innovate-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 923 views
  • 2 likes
  • 3 in conversation