BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello Everyone,

I am having trouble with finding the total score (tot_score) for the following data. My data has three variables (subject, visit, score) and it has the form:

100 1 60
100 2 62
100 3 62
100 4 65
100 5 70
101 1 58
101 2 59
101 3 62
101 4 63
101 5 65

I could transpose the data and get a final dataset with two obs (one for subject 100 and another for subject 101). I am not able to get any value for the newly introduced variable tot_score.

Also, I have one more question: If any of the visit is missing for any patient, what precaution I need to take?

Thanks and Regards
Sars
3 REPLIES 3
deleted_user
Not applicable
I would just use a PROC SQL

PROC SQL;
CREATE TABLE WORK.TOTALS AS
SELECT SUBJECT, SUM(SCORE) AS TOT_SCORE
FROM WORK.DATA
GROUP BY SUBJECT;

On how to deal with missing visits, it is really not a coding question, it is more a methdological protocol question. What is the protocol for dealing with missing scores/visits in your research? For example, some leave them out, some fill in with the average, some fill in with the extrapolated value. The point is, there is no real one way to deal with missing data, you have to have a protocol that is based on your research on what to do about them.

Ike Eisenhauer
deleted_user
Not applicable
Thanks for the response. I was thinking in terms of a retain statement, and got lost!!

Sars
Cynthia_sas
SAS Super FREQ
Hi:
In addition to PROC SQl, there are other methods of creating either reports or SAS datasets from your data:
[pre]

proc means data=visit sum n nway;
title '1) Proc Means Report';
class subject;
var score;
output out=mnout sum=totscore n=num_vis;
run;

proc tabulate data=visit f=comma8. out=work.tabout;
title '2) Proc Tabulate Report';
class subject visit;
var score;
table subject,
score * (sum='Tot Score' n='Num Visit')
/ rts=10;
run;

proc tabulate data=visit f=comma8.;
title '3) Proc Tabulate Report with Columns for IDs';
class subject visit;
var score;
table subject*
score * (sum='Tot Score' n='Num Visit')
/ rts=10;
run;

proc report data=visit nowd out=work.repout;
title '4) Proc Report Output';
column subject score n;
define subject / group 'Subject';
define score / sum 'Tot Score';
define n / 'Num Visit';
run;

proc print data=mnout;
title 'Data Set created by Proc Means #1';
run;

proc print data=tabout;
title 'Data Set created by Proc Tabulate #2';
run;

proc print data=repout;
title 'Data Set created by Proc Report #4';
run;
[/pre]

And you could use a DATA step program, as well. I'd consider this a how to summarize or create a summary data set problem more than a TRANSPOSE problem.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

Discussion stats
  • 3 replies
  • 994 views
  • 0 likes
  • 2 in conversation