SAS: Transform Transpose or SQL? -


i have 1 more quick question. have rather large data set looks following:

rank  count  score 1      100    10 romeo & juliet .  . shakespeare .  . 

i need somehow maintain rank, count, , score ( 1, 100, 10) , create new column name of book , column author.

is there way in sas? i'm drawing blank , appreciated. thanks!

first off, before give answer, key getting specific answers ask precise , detailed question.

from imprecise question , comments, think pieced problem. in fact, it's 1 i've encountered in past.

you said in comments data in csv file, example seems show data after attempted import. description, single observation spread across 3 lines of data in csv. assume data looks (i made second obs):

1,100,10 romeo & juliet shakespeare 2,90,9 old man , sea hemingway 

here's data step read file structured.

data books; infile '/folders/myfolders/books.csv' dlm=',' n=3 truncover; input rank score count #2 book $50. #3 author $30.; run; 

first, let me explain options on infile statement. option n=3 specifies 3 lines of input data available in input buffer corresponds number of lines needed compose single obs. we'll exploit option in input statement. truncover option ensures sas not continue read beyond end of line variables have values shorter specified length. instance, option allows me assign 50 char length informat book title, though book titles quite bit shorter that.

let's move on input statement. nothing special needed read rank, score , count since first line of each 3-line group standard, comma-delimited data. #2 notation tells sas move 2nd line of 3-line group read book title. of course, #3 moves line pointer last line of 3-line group read final variable author.

here's final output looks like:

enter image description here


Comments