Not sure where you are at in your learning journey so not sure if below code is already fitting for where you are at.
If you have an external text file then one way is to create the desired table structure as part of your data step that reads the table.
data want;
infile '/home/u63754936/STAT 725/Homework#1/Data Files HW1/Dataset3.txt'
firstobs=2
dsd
dlm=' '
truncover
;
length color $5;
do color='Black','Grey','Red','White';
input number @;
output;
end;
run;
proc print data=want;
run;
You will likely have to add a few options to the infile statement that instruct SAS how to read the external file - like for example dlm=.... to define the delimiting character used to separate the values.
If the do loop hasn't been covered yet in your classes then here another coding option.
data want;
infile '/home/u63754936/STAT 725/Homework#1/Data Files HW1/Dataset3.txt'
firstobs=2
dsd
dlm=' '
truncover
;
length color $5;
color='Black';
input number @;
output;
color='Grey';
input number @;
output;
color='Red';
input number @;
output;
color='White';
input number ;
output;
run;
The most important bit in this code is the @ at the end of the input statement that allows you to use multiple input statements without the cursor jumping onto the next line of input. Look up the details in the SAS docu.
