How to pick only diagonal observations from a SAS dataset

sas
data_wrangling
diagonal

#1

hi all,
here i have a sas dataset

1 23 houston usa
2 24 lucknow india
3 25 beijing china
4 34 johar malaysia

i wanna read the observations diagonally, and the result shud be …

1 24 beijing malaysia

being more specific:
1st row 1st col
2nd row 2nd col
3rd row 3rd col
4th row 4th col


#2

@Armaan,

Why do you want to read data set diagonally, is this a business requirement?

Steve


#3

That’s absolutely not a business requirement, but i came across this type of question in one of my recent interview’s, hoping an answer from someone, but still not cleared.

Regards,
@rman


#4

i got the answer but may b dats hard coding, using line hold specifiers

data s;
input # 1 id 1 # 2 age 3-5 # 3 city$ 6-13 # 4 country$ 12-20 ;
cards;
1 23 houston usa
2 24 lucknow india
3 25 beijing china
4 34 johar malaysia
;
run;

any suggestions are welcome