3
votes

I have input data that includes the variable name, an equal sign, and a value in the data. How can I input that data?

My input data is as follows:

name=Linda english=95 math=94 science=90
name=Susan math=88 english=91 science=90
name=Mary Louise math=90 english=84 science=81

What I've tried so far:

  data one;
    input name $ subject $;
cards;

My desired output data:

Obs    name           math
1     Linda           94
2     Susan           88
3     Mary Louise     90
1

1 Answers

5
votes

Assuming you are trying to read input from the raw data, the input method below - using the equal sign (=) after the variable name - allows you to read that format of data.

data one;                                                                                                                               
 input name=$20. english= math= science=;                                                                                               
cards;                                                                                                                                  
name=Linda english=95 math=94 science=90                                                                                                
name=Susan math=88 english=91 science=90                                                                                                
name=Mary Louise math=90 english=84 science=81                                                                                          
;                                                                                                                                       

run;