BookmarkSubscribeRSS Feed
MKhandelwal
Fluorite | Level 6
Hi,
I have a matrix like this. The number of SP can be more than 2 next time. So its value is stored in a macro variable &nosp. Number of MP is stored in &nomp. Number of SSP is stored in &nossp.

MP_SP_SSP SP1 SP2 Mean SP1 SP2 Mean SP1 SP2 Mean
SSP1 24.00 24.50 24.25 39.70 34.40 37.05 27.30 27.60 27.45
SSP2 31.50 24.50 28.00 35.60 34.30 34.95 32.90 27.60 30.25
Mean 27.75 24.50 26.13 37.65 34.35 36.00 30.10 27.60 28.85

I want the output like this. SP1 and SP2 are bifurcated under MP1. Next SP1 and SP2 bifurfacted under MP2 and similarly for next.

MP1 MP2 MP3
MP_SP_SSP SP1 SP2 Mean SP1 SP2 Mean SP1 SP2 Mean
SSP1 24.00 24.50 24.25 39.70 34.40 37.05 27.30 27.60 27.45
SSP2 31.50 24.50 28.00 35.60 34.30 34.95 32.90 27.60 30.25
Mean 27.75 24.50 26.13 37.65 34.35 36.00 30.10 27.60 28.85

Please take me out of it.

The values are stored in columns COLUMN1-COLUMN9. COLUMN3, COLUMN6 & COLUMN9 has label as Mean.
I am trying a code something like this but with lots of errrors.

[pre]
Proc Report Data=new3way Nowd style(header)=[TEXTALIGN=C] headline headskip spacing=1;
Column ('_' &main._&sub._&subsub %Do jj=1 %To &nomp;
('MP&jj' COLUMN_1-COLUMN_&nosp)
%End;
COLUMN_%eval(&nomp*&nomp));
Define &main._&sub._&subsub/Display;
%Do jj=1 %To %eval(&nomp*&nomp);
COLUMN_&jj/Display;
%End;
Run;
[/pre]
1 REPLY 1
MKhandelwal
Fluorite | Level 6
The problem is done with the following code.
[pre]
%Let r=2; %Let s=1; %Let t=1; %Let mp=&nomp;
Proc Report Data=new3way Nowd style(header)=[TEXTALIGN=C];
Column (MP_SP_SSP ("_MP^{sub 1 }_" COLUMN_1-COLUMN_&mp) /*Macro variable 'mp' contains No. of main plots*/
%Do jj=2 %To &nomp;
("-MP^{sub &jj }-" COLUMN_%eval(&nomp*&s+1)-COLUMN_%eval(&nomp*&r))
%Let r = %eval(&r+1);
%Let s = %eval(&s+1);
%End;
) ;

Define &main._&sub._&subsub/Display;
%Do jj=1 %To %eval(&nomp*&nomp);
%If &jj ~= %eval(&nomp*&t) %Then
%Do;
Define COLUMN_&jj/Display;
%End;
%Else
%Do;
Define COLUMN_&jj/Display Right;
%Let t = %eval(&t+1);
%End;
%End;
Run;
[/pre]

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
  • 1 reply
  • 866 views
  • 0 likes
  • 1 in conversation