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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 640 views
  • 3 likes
  • 3 in conversation