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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 2362 views
  • 3 likes
  • 5 in conversation