i want to create labels for a dataset using proc sql.
i used the code
proc sql; select PRODUCT_ID label="Line number" from a6.SMB; quit;
but in the result the column name product_id is changed to line number.
In the original smb data-set the label has not been modified .
Why is it not working ?
@novinosrin The OP's code did not create a table so there wasn't a table to assign a permanent label to the variable. It assigned a label to the variable in the output to the results window for a select.
proc sql;
select sex label='Gender Label'
from sashelp.class;
quit;
Won't change the label in sashelp.class which may be the OP intent. May, that's why I asked for clarification of intent.
You didn't create a table, you only displayed results and they default to the Labels in presentation.
If you want a data set, add a CREATE TABLE statement and then you can check the the variable name and label are different. If you'd like to apply a label to an already created data step and cannot back up to do so in another data step or proc sql, you can use PROC DATASETS to modify the library.
By table do you mean a "report table" or "a newly created dataset for further use" or "an existing dataset"?
Your code created a report table in the results. It did not create a data set or modify an existing one.
Proc Datasets is the preferred way to modify existing data sets.
proc datasets library = a6; modify SMB; label Product_id = "Line Number"; quit;
There are options to suppress some of the information you'll get when running the procedure such as NODETAILS, NOLIST and/or NOPRINT on the procedure statement.
Are you sure? My test has yielded the expected results
proc sql;
create table want as
select sex label="gender"
from sashelp.class;
quit;
proc contents;
run;
Proc contents -->SAS Output
Sex | Char | 1 | gender |
@novinosrin The OP's code did not create a table so there wasn't a table to assign a permanent label to the variable. It assigned a label to the variable in the output to the results window for a select.
proc sql;
select sex label='Gender Label'
from sashelp.class;
quit;
Won't change the label in sashelp.class which may be the OP intent. May, that's why I asked for clarification of intent.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.