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
data n;
i='SAS' ;
do i= 1 to 100;
output;
end;
stop;
proc print;
run;

Desired ouput 

SAS word prints 100 times

1 ACCEPTED SOLUTION

Accepted Solutions
RichardDeVen
Barite | Level 11

Use a separate variable for your word.  You can repurpose automatic variable _N_ to be your loop index variable.  Automatic variables do not become part of the output data set.

data have;
  word = 'SAS' ;
  do _n_ =  1 to 100;
    output;
  end;
run;
proc print; run;

PROC PRINT can not suppress column headers.  If you really want only the word to appear you will have to use PROC REPORT which can suppress column headers with option NOHEADERS.  

title; footnote;
options nodate nonumber nocenter;
proc report noheader;
run;

If you mean to produce listing hardcopy directly from the procedure change the printing destination using PROC PRINTTO.

filename hardcopy printer;    * file reference to default printer;
proc printto print=hardcopy;  * redirect output to printer device;
proc report noheader;
proc printto print=print;     * reset output to default;
run;
filename hardcopy clear;      

View solution in original post

8 REPLIES 8
BrahmanandaRao
Lapis Lazuli | Level 10
anyone can give answer
BrahmanandaRao
Lapis Lazuli | Level 10
data n;
i=input(SAS,4.);
do i= 1 to 100;
output;
end;
stop;
proc print;
run;
Kurt_Bremser
Super User

This statement:

i=input(SAS,4.);

is not necessary, as you set variable i in the DO statement anyway.

 

Please describe what you want to do in plain language; the data you have, and the data you want.

BrahmanandaRao
Lapis Lazuli | Level 10
SAS PRINT 100 TIMES
BrahmanandaRao
Lapis Lazuli | Level 10
I want output
SAS word 100 times
RichardDeVen
Barite | Level 11

Use a separate variable for your word.  You can repurpose automatic variable _N_ to be your loop index variable.  Automatic variables do not become part of the output data set.

data have;
  word = 'SAS' ;
  do _n_ =  1 to 100;
    output;
  end;
run;
proc print; run;

PROC PRINT can not suppress column headers.  If you really want only the word to appear you will have to use PROC REPORT which can suppress column headers with option NOHEADERS.  

title; footnote;
options nodate nonumber nocenter;
proc report noheader;
run;

If you mean to produce listing hardcopy directly from the procedure change the printing destination using PROC PRINTTO.

filename hardcopy printer;    * file reference to default printer;
proc printto print=hardcopy;  * redirect output to printer device;
proc report noheader;
proc printto print=print;     * reset output to default;
run;
filename hardcopy clear;      

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 8 replies
  • 910 views
  • 0 likes
  • 3 in conversation