Community talk about communities.sas.com. Meta!

Base SAS Scenario

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 11
Accepted Solution

Base SAS Scenario

i have dataset like 

fname lname

john    kilber

 

and i want output like this 

 

fname lname

john    kilber

john    kilber

john    kilber

john    kilber

           kilber

 

 

how to do this please help me out... 


Accepted Solutions
Solution
‎07-28-2017 01:36 PM
Super User
Posts: 5,513

Re: Base SAS Scenario

Posted in reply to Sharad_Pujari

How about:

 

data want;

set have;

output;

output;

output;

output;

fname=' ';

output;

run;

View solution in original post


All Replies
Super User
Super User
Posts: 7,977

Re: Base SAS Scenario

Posted in reply to Sharad_Pujari

Do loops?

data want (drop=i);
  set have;
  do i=1 to 5;
    output;
  end;
run;
Occasional Contributor
Posts: 11

Re: Base SAS Scenario

yeah it will work but it will show both fname and lname record at same no of observation but i want fname 4 times and lname 5 times
Super User
Super User
Posts: 7,977

Re: Base SAS Scenario

Posted in reply to Sharad_Pujari

Really not the most difficuly update:

data want (drop=i);
  set have;
  do i=1 to 5;
    if i=5 then fname="";
    output;
  end;
run;
Occasional Contributor
Posts: 11

Re: Base SAS Scenario

thanks
Super User
Posts: 11,343

Re: Base SAS Scenario

Posted in reply to Sharad_Pujari

Is there some logic that the fifth version does not have the fname? is it always to create exactly 5 records?

Occasional Contributor
Posts: 11

Re: Base SAS Scenario

no suppose you are working in comany and client want output as i shown above

Solution
‎07-28-2017 01:36 PM
Super User
Posts: 5,513

Re: Base SAS Scenario

Posted in reply to Sharad_Pujari

How about:

 

data want;

set have;

output;

output;

output;

output;

fname=' ';

output;

run;

☑ This topic is solved.

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

Discussion stats
  • 7 replies
  • 415 views
  • 0 likes
  • 4 in conversation