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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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