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;
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.
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.