'Properly define variables using input statement

How can I change all the column to $8.?

Below is my code

data workout; 
input Day1-Day7 $8. ;  
datalines;`   
chest leg back rest chest leg back;      
run;

And the result only show the last column Day7 with back and other column just show . only

sas


Solution 1:[1]

First of all, your code will likely not produce any output. The semicolon ; ending the data enumeration should be located on a separate line, not on the same line as your records.

Secondly, only Day7 has a value because it is the only variable that you specify as character. Make sure to use parenthesis around the type and length and use the colon : modifier to tell SAS to read the variables until there is a space or delimiter (:$8.).

Also, the run; at the end is not needed, but does not harm any ;)

data workout;
input (Day1-Day7) (:$8.);
datalines;
chest leg back rest chest leg back
; 
chest leg back rest chest leg back

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1