BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Wolverine
Quartz | Level 8

I have several statistics that are reported for 17 case definitions that I'm testing.  I'd like to put them in a format that is easier to read and make comparisons.  The final goal is to put them together in an Excel file, but I think I can modify syntax I already have to handle that IF I can get SAS to display the output correctly.  Here is my current code, which displays the results on several rows instead of on a single row.  I'm also attaching pix of the SAS freq output and a shell of what I would like the final table to look like.

 

ODS TRACE ON;
DATA temp.claim_line_it_DX_def&defnumb._all;
	MERGE temp.claim_line_it_DX_def&defnumb._TP temp.claim_line_it_DX_def&defnumb._FP
		temp.claim_line_it_DX_def&defnumb._FN temp.claim_line_it_DX_def&defnumb._TN
		temp.claim_line_it_DX_def&defnumb._Excl;
	BY ROWID;
	
Sensitivity = TP_count / (TP_count + FN_count);
Specificity = TN_count / (TN_count + FP_count);
Area_under_curve = (Sensitivity + Specificity)/2;

title1 "Case Definition &defnumb. - A count of at least 1 SCA claim (D5700, D5701, D5702)(Version &version.)";
PROC FREQ;
	TABLES TP_count FP_count FN_count TN_count Excl_count Sensitivity Specificity
			Area_under_curve;

ODS OUTPUT OneWayFreqs(match_all)=temp.results_v&version._Def&defnumb.;
PROC FREQ DATA = temp.claim_line_it_DX_def&defnumb._all;
	TABLES TP_count FP_count FN_count TN_count Excl_count Sensitivity Specificity
			Area_under_curve;
RUN;

ODS LISTING;
PROC PRINT DATA = temp.results_v&version._Def&defnumb.;
RUN;

ODS TRACE OFF;

SASfreq example.jpgExcel output example.jpg 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Use PROC TRANSPOSE on the 

temp.results_v&version._Def&defnumb.

And then proc print that result. 

View solution in original post

2 REPLIES 2
Reeza
Super User

Use PROC TRANSPOSE on the 

temp.results_v&version._Def&defnumb.

And then proc print that result. 

Wolverine
Quartz | Level 8

Thanks!  Proc Transpose sent me in the right direction, but I had to play with it a bit to get the proper output.  Here is the final section of code

 

%macro defmerge (defnumbm,defname);
%let version=9;

title1 "Def&defnumbm. &defname.";

ODS TRACE ON;
ODS OUTPUT OneWayFreqs(match_all)=temp.results_v&version._Def&defnumbm.;
RUN;

PROC TRANSPOSE DATA = temp.claim_line_it_DX_Def&defnumbm._all out = temp.results_v&version._Def&defnumbm._t;

PROC TRANSPOSE DATA = temp.results_v&version._Def&defnumbm._t out = temp.results_v&version._Def&defnumbm.(DROP=_NAME_);

ODS LISTING;
PROC PRINT DATA = temp.results_v&version._Def&defnumbm. ;
RUN;

ODS TRACE OFF;

%mend;
%defmerge(1, - A count of at least 1 SCA claim)
%defmerge(2, - A count of at least 2 SCA claims)
%defmerge(3, - A count of at least 3 SCA claims)

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
  • 1043 views
  • 0 likes
  • 2 in conversation