- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 ?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 |
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.