DATA Step, Macro, Functions and more

Create unique rows

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

Create unique rows

Am trying to create unique row values depending on a numeric value. like If x=6, create 6 unique rows in a dataset. Any help is appreciated. 


Accepted Solutions
Solution
‎10-04-2016 12:58 PM
Super User
Posts: 5,504

Re: Create unique rows

Have you tried something simple and direct like:

 

data want;

set have;

do rownum=1 to x;

   output;

end;

run;

View solution in original post


All Replies
Solution
‎10-04-2016 12:58 PM
Super User
Posts: 5,504

Re: Create unique rows

Have you tried something simple and direct like:

 

data want;

set have;

do rownum=1 to x;

   output;

end;

run;

Contributor
Posts: 25

Re: Create unique rows

Posted in reply to Astounding
Thank you
Super User
Posts: 11,343

Re: Create unique rows

It would help to provide some example of what other values may be involved.

 

Basically

 

Data want;

  x=6;

  do i=1 to x;

      output;

   end;

run;

 

will generate a given number of additional records based on the value of a variable. If the Variable X is a data set and is used on a SET statement then you will get additional records with the same values for all the other variables (except i).

 

 

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 262 views
  • 0 likes
  • 3 in conversation