I have updated your question to include the code you provided in comments and the error message that I get when I run that code.
In future, when writing questions on StackOverflow, it is more helpful if you include the full code AND any error messages in your question, that way people can help point out the specific problem and help you understand better.
I must admit the SAS documentation for an entry-level user is not the easiest to follow and the specific page for ALTER TABLE does not include any examples. However, I did find some here, in the SAS Docs:
proc sql;
alter table sql.newcountries
add density num label='Population Density' format=6.2;
quit;
There's a bit more than you need here, but let's go through each component:
add - tells PROC SQL you want to add a column
density - the name of your column
num - the data type of your column, in SAS this is either (char or num)
label= - the label for your column
format= - the format for your column
To update your code, you need to do a couple of things:
Switch around the variable name and the type
Update student name so it has no spaces, you can do this using an underscore student_name
proc sql;
alter table students add student_name char;
quit;
The resulting log:
70 alter table students add student_name char;
NOTE: Table WORK.STUDENTS has been modified, with 2 columns.
The problem you might now encounter is that SAS initialises all columns with a length of 8, so to specify a longer length, use length=:
proc sql;
alter table students add long_student_name char length=200;
quit;
If you've read this far and this has helped, please remember to bear in mind my tips about including more information in your question - you are far more likely to receive a good quality answer that way.
I have updated your question to include the code you provided in comments and the error message that I get when I run that code.
In future, when writing questions on StackOverflow, it is more helpful if you include the full code AND any error messages in your question, that way people can help point out the specific problem and help you understand better.
I must admit the SAS documentation for an entry-level user is not the easiest to follow and the specific page for
ALTER TABLEdoes not include any examples. However, I did find some here, in the SAS Docs:So let's look at one of those examples:
There's a bit more than you need here, but let's go through each component:
To update your code, you need to do a couple of things:
student nameso it has no spaces, you can do this using an underscorestudent_nameThe resulting log:
The problem you might now encounter is that SAS initialises all columns with a length of 8, so to specify a longer length, use
length=:If you've read this far and this has helped, please remember to bear in mind my tips about including more information in your question - you are far more likely to receive a good quality answer that way.