BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Son_Of_Krypton
Fluorite | Level 6
data number;
input number;
cards;
1
2
3
4
5
;
run;

 

i want output like this :

 

Number
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5

please suggest a way to do this 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Why do you want to do this?

 

One way (among many).

 

data number;
input number;
cards;
1
2
3
4
5
;
run;

data want;
   set number;
   do i=1 to 3;
      output;
   end;
run;

proc sort data=want out=want(drop=i);
   by i;
run;

View solution in original post

8 REPLIES 8
Amir
PROC Star

Hi,

 

As you just want a suggestion, see what the following does then try and change it to suit your needs. The input data set has 19 observations, but it is being read twice:

 

data want;
   set sashelp.class
       sashelp.class
   ;
run;

 

If you are new to SAS, they do have some basic free training and paid-for training options available:

 

http://support.sas.com/training/

 

If you are still stuck then show us what code you have tried and the log with any messages.

 

 

Regards,

Amir.

PeterClemmensen
Tourmaline | Level 20

Why do you want to do this?

 

One way (among many).

 

data number;
input number;
cards;
1
2
3
4
5
;
run;

data want;
   set number;
   do i=1 to 3;
      output;
   end;
run;

proc sort data=want out=want(drop=i);
   by i;
run;
Kurt_Bremser
Super User

Another idea, in one data step:

data want;
do i = 1 to 3;
  do j = 1 to nobs;
    set number nobs=nobs point=j;
    output;
  end;
end;
drop i j;
stop;
run;

 

 

PS and use more intelligent subjects in the future. "base sas" in the Base SAS Programming community is not meaningful AT ALL..

data_null__
Jade | Level 19
proc surveyselect out=number3 reps=3 rate=1 noprint;
   run;
novinosrin
Tourmaline | Level 20
data number;
input number;
cards;
1
2
3
4
5
;
run;

data want;
set number number number;
run;
novinosrin
Tourmaline | Level 20
proc sql;
create table want as
select b.number 
from number(where=(number<=3)) a, number b
order by a.number,b.number;
quit;
novinosrin
Tourmaline | Level 20
data want;
set number(where=(number<=3));
do _n_=1 to nobs;
set number nobs=nobs point=_n_;
output;
end;
run;
novinosrin
Tourmaline | Level 20
data want;
   if _N_ = 1 then do;
   if 0 then set number;
    dcl hash h(dataset:"number", ordered: 'yes');
    dcl hiter i('h');
      h.defineKey('number');
      h.defineData('number');
      h.defineDone();
   end;
set number (where=(number<=3));
do while (1);
if i.next() ne 0 then return;
  output;
end;
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 8 replies
  • 1107 views
  • 1 like
  • 6 in conversation