BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Saleem
Calcite | Level 5

Hi Team,

data ds1;

infiledatalines;

input star;

cards;

*

**

***

****

*****

run;

how to create 10000 stars at a time by using sas

 

Thanks in advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Please use descriptive subject lines in the future, so others do not need to do that for you. Using just "sas" (sic) in the SAS communities does not shine a positive light on a poster's intelligence.

 

For your question:

data want (compress=yes);
length stars $32767;
do i_n_= 1 to 10000;
  stars = repeat('*',_n_);
  output;
end;
run;

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

Please use descriptive subject lines in the future, so others do not need to do that for you. Using just "sas" (sic) in the SAS communities does not shine a positive light on a poster's intelligence.

 

For your question:

data want (compress=yes);
length stars $32767;
do i_n_= 1 to 10000;
  stars = repeat('*',_n_);
  output;
end;
run;
Astounding
PROC Star

The REPEAT function has a quirk ... it starts with the first string, and then repeats it the number of times in the second parameter.  So the first value generated would be ** rather than *.  I imagine that a value of 0 for the second parameter is OK, and that the loop should go from 0 to 9999 instead of 1 to 10000.

Kurt_Bremser
Super User

I must admit that I just know that the function exists, but have never used it. And, to my shame, I did not mention the code is untested (I am on my tablet at the moment while watching NFL Gamepass).

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