BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sathwik
Calcite | Level 5

I had observations that each and every observations will repeat 5 times in simple program. suggest me any one.

data Ex001;
	input Name $ Designee $ 20-32 Department $;
	datalines;
		Madhu      Jr_Associate  QA
		Sathwik    Jr_Associate  PB
		Mohan      Manager       PB
		Raja       Manager       QA
		Kiran      Manager       BI
		Sainath    Manager       CL
		;
	
run;

Proc print data = Ex001;
run;

  Which i want out putUntitled.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

When putting test data in a datastep like that, ensure the data and the datalines statement all appear left aligned, otherwise you may get issues as SAS reads from position one on each row (you will note how you are putting positional reading in there as well, not a good idea).  Also, avoid using tab characters in code, these render differently between operating systems/tools.  Use spaces to indent, you can setup SAS to use spaces when pressing tabs - in base SAS it is under the options (spaces always render as 1 character regardless of os/tool, where tabs are different).

data ex001;
  input name $ designee $ department $;
datalines;
Madhu      Jr_Associate  QA
Sathwik    Jr_Associate  PB
Mohan      Manager       PB
Raja       Manager       QA
Kiran      Manager       BI
Sainath    Manager       CL
;
run;

data want (drop=i);
  set ex001;
  do i=1 to 5;
    output;
  end;
run;

  

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

When putting test data in a datastep like that, ensure the data and the datalines statement all appear left aligned, otherwise you may get issues as SAS reads from position one on each row (you will note how you are putting positional reading in there as well, not a good idea).  Also, avoid using tab characters in code, these render differently between operating systems/tools.  Use spaces to indent, you can setup SAS to use spaces when pressing tabs - in base SAS it is under the options (spaces always render as 1 character regardless of os/tool, where tabs are different).

data ex001;
  input name $ designee $ department $;
datalines;
Madhu      Jr_Associate  QA
Sathwik    Jr_Associate  PB
Mohan      Manager       PB
Raja       Manager       QA
Kiran      Manager       BI
Sainath    Manager       CL
;
run;

data want (drop=i);
  set ex001;
  do i=1 to 5;
    output;
  end;
run;

  

sathwik
Calcite | Level 5
thank you
sathwik

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 8606 views
  • 0 likes
  • 2 in conversation