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;
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.
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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.