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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 7913 views
  • 0 likes
  • 2 in conversation