BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BrahmanandaRao
Lapis Lazuli | Level 10
Can we print pattern like below using SAS
* 
* * 
* * * 
* * * * 
* * * * * 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
data _null_;
   do n=0 to 4;
      a=repeat('* ', n);
      put a;
   end;
run;

 

prints 

 

*
* *
* * *
* * * *
* * * * *

 

View solution in original post

11 REPLIES 11
PeterClemmensen
Tourmaline | Level 20
data _null_;
   do n=0 to 4;
      a=repeat('* ', n);
      put a;
   end;
run;

 

prints 

 

*
* *
* * *
* * * *
* * * * *

 

BrahmanandaRao
Lapis Lazuli | Level 10

Thank You 

 

Brilliant Code

Kurt_Bremser
Super User

Yes.

 

Spoiler
data _null_;
file print;
length text $100;
do i = 1 to 5;
  text = catx(' ',text,'*');
  put text;
end;
run;
BrahmanandaRao
Lapis Lazuli | Level 10

Thank You  sir

 

very impressed your outstanding  coding skills

Ksharp
Super User

Just have some fun.

 

data _null_;
   do i=1 to 5;
      do j=1 to i;
        put '* ' @;
	  end;
	    put;
   end;
run;
 
ballardw
Super User

And another approach:

proc format library=work;
value stars
1='*'
2='* *'
3='* * *'
4='* * * *'
5='* * * * *'
;

data _null_;
do i = 1 to 5;
  put i stars.;
end;
run;

Though harder to maintain if you need a 20 row lower triangle.

BrahmanandaRao
Lapis Lazuli | Level 10

Thank You sir

BrahmanandaRao
Lapis Lazuli | Level 10

Thank Your

 

what if right angle triangle  

 

Ksharp
Super User

Sure. Not a big deal .

 

data _null_;
   do i=5 to 1 by -1;
      do j=5 to i by -1;
        put @(2*j) '* ' @;
	  end;
	    put;
   end;
run;
BrahmanandaRao
Lapis Lazuli | Level 10

Thank You Ksharp

 

Your are really sharp Smiley Happy

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 11 replies
  • 2171 views
  • 3 likes
  • 5 in conversation