Date: Sat, 24 Sep 2011 16:11:45 -0400
Reply-To: Mahesh <peesari.mahesh@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mahesh <peesari.mahesh@GMAIL.COM>
Subject: Build pyramid with sas code
HI all,
I have a below values in data set and how can i build pyramid?
*
**
***
****
*****
i want to move first row to start at position 5 and later on decreasing as
moving to next record.
My output should be this way.
*
* *
* * *
* * * *
* * * * *
* * * * * *
please help out.
I was successful for passing dynamic values which will generate tables with
star values for x no of rows,but i am unable to arrange in proper way to
build a pyramid.
Please check below code:
data re;
x ='*';
/*pass any value at array*/
array m(10) $;
do i = 1 to 10;
if m(i) = m(i) then do ;
m(i) = x;
output;
end;
end;
drop i b x;
run;
/*make var statement in transpose equal to no variables*/
proc transpose data=re out=rtrt;
var m1 - m10;
run;
data rtrt1;
set rtrt;
/*try to conctenate without writing all thecolumn names*/
xd = compress(col1 || col2 || col3 || col4 || col5 || col6 || col7 ||col8 ||
col9 ||col10);
t = _n_;
drop col1 -col10 ;
run;
proc sort data = rtrt1 out=v(drop=t _name_);
by descending t;
run;
proc print;
run;
proc sql;
select distinct(xd) into : x1 - :x10 from v;
quit;
DATA _NULL_;
set v;
PUT xd;
run;
Thanks,
Mahesh P