DATA Step, Macro, Functions and more

How to get multiple same obs from a single record of raw data

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

How to get multiple same obs from a single record of raw data

Hey i have a data like this...

data DS1;
INFILE DATALINES;
INPUT NAME $;
DATALINES;
LION

TIGER
;
RUN;

 

output should be a dataset with 8 observations and it should look like

name

LION

LION

LION

LION

TIGER

TIGER

TIGER

TIGER

 


Accepted Solutions
Solution
‎07-27-2017 02:54 AM
PROC Star
Posts: 761

Re: How to get multiple same obs from a single record of raw data

Posted in reply to Bhargav_Movva

Like this

 

data DS1;
INFILE DATALINES;
INPUT NAME $;
DATALINES;
LION
TIGER
;
RUN;

data want(keep=name);
	set ds1;
	do i=1 to 4;
		output;
	end;
run;

View solution in original post


All Replies
Super User
Posts: 7,830

Re: How to get multiple same obs from a single record of raw data

Posted in reply to Bhargav_Movva
data ds2;
set ds1;
do i = 1 to 4;
  output;
end;
drop i;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎07-27-2017 02:54 AM
PROC Star
Posts: 761

Re: How to get multiple same obs from a single record of raw data

Posted in reply to Bhargav_Movva

Like this

 

data DS1;
INFILE DATALINES;
INPUT NAME $;
DATALINES;
LION
TIGER
;
RUN;

data want(keep=name);
	set ds1;
	do i=1 to 4;
		output;
	end;
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 101 views
  • 1 like
  • 3 in conversation