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

I want to create a new dataset with only the element in the second row of the second column. Is there a way to do this? I would prefer not to use proc iml

 

For example, I want to transform data1 to data2

data test1;
 input a b;
 datalines;
10 40 70
50 60 90
18 70 30 
;
run;

data test2;
input c;
datalines;
60
;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Pretty peculiar request:

In the dataset options in the second data step FIRSTOBS= is the row number to start reading data, OBS = is the row number to stop reading data.

data test1;
 input a b;
 datalines;
10 40 70
50 60 90
18 70 30 
;
run;

data want;
   set test1 (firstobs=2 obs=2  keep=b);
run;

If you really want the variable to be named C add a rename, either statement or dataset option.

 

View solution in original post

1 REPLY 1
ballardw
Super User

Pretty peculiar request:

In the dataset options in the second data step FIRSTOBS= is the row number to start reading data, OBS = is the row number to stop reading data.

data test1;
 input a b;
 datalines;
10 40 70
50 60 90
18 70 30 
;
run;

data want;
   set test1 (firstobs=2 obs=2  keep=b);
run;

If you really want the variable to be named C add a rename, either statement or dataset option.

 

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
  • 1 reply
  • 1650 views
  • 1 like
  • 2 in conversation