BookmarkSubscribeRSS Feed
thanikondharish
Fluorite | Level 6

I have written one code to create stars line wise.for your reference please find attachment file1.

How to get values like from file2 .

file1-code:


data _null_ ;
j=24 ;
do i=24 to 0 by -2;
b=repeat('*',i) ;
c=(j-i)/2 ;
put +c b ;
end;
run;

 

3 REPLIES 3
Ksharp
Super User
data _null_ ;
do i=0 to 10 ;
b=repeat('* ',i) ;
put  b ;
end;
do i=9 to 0 by -1;
b=repeat('* ',i) ;
put  b ;
end;
run;
Tom
Super User Tom
Super User

I don't understand what the question is.

PS Please do not paste pictures as attachments. Use the camera icon to insert them into the message instead.

PPS Please do not paste picture of text. Use the Insert Code icon (looks like < / >) to paste the actual text instead.

2616  data _null_ ;
2617  j=24 ;
2618  do i=24 to 0 by -2;
2619  b=repeat('*',i) ;
2620  c=(j-i)/2 ;
2621  put +c b ;
2622  end;
2623  run;

*************************
 ***********************
  *********************
   *******************
    *****************
     ***************
      *************
       ***********
        *********
         *******
          *****
           ***
            *
NOTE: DATA statement used (Total process time):

 

Tom
Super User Tom
Super User

Are you looking to do something like this?

2679  data _null_ ;
2680    length line $80 ;
2681    do i=0 to 24 by 2 ,22 to 0 by -2;
2682      line=repeat('*',i) ;
2683      put line ;
2684    end;
2685  run;

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

Or perhaps like this

2624  data _null_ ;
2625    length line $80 ;
2626    do i=0 to 10 ,9 to 0 by -1;
2627      line=cat(repeat(' ',10-i),repeat('*',2*i)) ;
2628      put line $char80.;
2629    end;
2630  run;

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

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

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1076 views
  • 2 likes
  • 3 in conversation