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

Untitled.jpg

data Examplex;
	input Name $ 9-19 Designee $ 20-32  Department $;
	datalines;
		Madhu      Jr_Associate  QA
		Sathwik    Jr_Associate  PB
		Mohan      Manager       PB
		Raja       Manager       QA
		Kiran      Manager       BR
		Sainath    Manager       CL
		;
run;

proc print data = Examplex;
run;

I had table which is given in Photo and Program. By using this table i want create new table by taking two observations in that given table. 

 

 

1 ACCEPTED SOLUTION

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

Which is it?  

"some random two observations"

or 

"When i need particular 2 and 5 observations"?

 

If you know the two observations then you where clause it for that:

data want;
  set have;
  if _n_ in (2,5);
run;
proc print data=want;
run;

For positional, or you could change the where to be the values from those rows.

View solution in original post

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Do stop putting datalines indented.  SAS reads data from position 1.

For this "By using this table i want create new table by taking two observations in that given table. " - you will need to clarify, do you want the first two observations, some random two?

 

sathwik
Calcite | Level 5
some random two observations
PeterClemmensen
Tourmaline | Level 20
proc surveyselect data=Examplex out=want noprint
     seed=1234 method=srs
     sampsize=2;
run;
sathwik
Calcite | Level 5
When i need particular 2 and 5 observations at that time which code we need
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Which is it?  

"some random two observations"

or 

"When i need particular 2 and 5 observations"?

 

If you know the two observations then you where clause it for that:

data want;
  set have;
  if _n_ in (2,5);
run;
proc print data=want;
run;

For positional, or you could change the where to be the values from those rows.

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
  • 6 replies
  • 1741 views
  • 4 likes
  • 3 in conversation