OK. How about this one . data have; input x $; n=0; do i=length(x) to 1 by -1; n+1; if mod(n,2)=0 then substr(x,length(x)-n+1,1)=' '; y=reverse(substr(x,2))||x; end; cards; * ** *** **** ***** ; run;
What is pyramid?
HI PG,
> >
> > 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.
data _null_;
put ' * ';
put ' *** ';
put ' ***** ';
put '*******';
run;
Submit. Find your pyramid erected inside the log.
i have to get the output by hard coding (by doing iterations).
@Rick make many different type of Christmas tree . http://blogs.sas.com/content/iml/2013/12/18/christmas-tree-matrix.html http://blogs.sas.com/content/iml/2014/12/10/xmas-tree-pascals-triangle.html
Hi ksharp,
Thanks for helping me,
pyramid must be build using normal coding not by matrix or graph plot.
> >
> > 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.
@sandeep79 wrote:
Hi ksharp,
Thanks for helping me,
pyramid must be build using normal coding not by matrix or graph plot.
How are graph plots "abnormal"?
What is your destination? A text file? HTML? RTF? PDF?
Note that the FONT used to display the output can result in an uneven appearance because of the way spaces may be displayed with proportional fonts (which is one possible reason to use graphic output)
Sounds like an algorithm puzzle. Perhaps a class assignment?
Given a list of records with asterisks left-aligned, build a pyramid (centered) version of these records? Sounds like you need to:
It could be a fun little programming golf puzzle...but maybe people would be more inclined to help if they knew this wasn't just your homework? Or an interview question? Is there a business goal?
OK. How about this one . data have; input x $; n=0; do i=length(x) to 1 by -1; n+1; if mod(n,2)=0 then substr(x,length(x)-n+1,1)=' '; y=reverse(substr(x,2))||x; end; cards; * ** *** **** ***** ; run;
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.
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.