So I have a data set with 3 variables, I want to remove the dash symbol and split the data into 4 rows of data when var2 contains number and var3 contains a letter., and var2 will be under var1 after splitting. For example “1 -2 C” will be split into:
var1 var2 var3
1 . .
1 . C
2 . .
2 . C
and split the data into 2 rows of data if var2 contains number and var3 does not contain anything. For example “3 4 .” Will be split into:
3 . .
4 . .
Other data will remain the same.
Here is my data:
Data have;
Input var1 $ var2 $ var3 $20.;
Cards;
1 -2 C
3 4 .
7 -9 F
10 . .
12 . H
15 B .
run;
And my expected output is:
var1 var2 var3
1 . .
1 . C
2 . .
2 . C
3 . .
4 . .
7 . .
7 . F
9 . .
9 . F
10 . .
12 . H
15 B .
I can get “3 4 .” into
3 . .
4 . .
But I cannot figure out how to split the data into 4 for the condition above. Thank you!!