- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-09-2008 11:21 AM
(3164 views)
We know in STATA, we can put "notes" in the data set as below, is there a similar thing in SAS that allows us to attach some comments to a SAS data set? Thanks,
In STATA:
Syntax
Attach notes to dataset
notes [varname]: text
In STATA:
Syntax
Attach notes to dataset
notes [varname]: text
7 REPLIES 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
It depends on what you mean. You can attach a dataset LABEL to the whole dataset (1-40 characters), or you can assign a LABEL to each variable.
Either use the LABEL data set option when you create the SAS data set:
[pre]
data newfile(label='Sesame Street Chars');
kermit = 'green';
oscar = 'grouch';
bigbird = 'happy';
run;
[/pre]
Or use a PROC DATASETS MODIFY statement to add a label after the dataset has been created:
[pre]
proc datasets library=work nolist;
modify file2 (label='Notes About Data Go Here');
quit;
[/pre]
When you run PROC CONTENTS, or otherwise examine the data set attributes, you will see the LABEL.
To assign a Label to every variable name, you would use a LABEL statement in the code itself when you create the file OR in PROC DATASETS. For example:
[pre]
data newfile(label='Sesame Street Chars');
kermit = 'green';
oscar = 'grouch';
bigbird = 'happy';
label kermit = 'Kermit the Frog'
oscar = 'Oscar the Grouch'
bigbird = 'Big Bird';
run;
[/pre]
For more information on PROC DATASETS, refer to the documentation. For more information on how SAS labels are used, look for the section in the documentation that talks about SAS variables and attributes of a SAS dataset.
cynthia
It depends on what you mean. You can attach a dataset LABEL to the whole dataset (1-40 characters), or you can assign a LABEL to each variable.
Either use the LABEL data set option when you create the SAS data set:
[pre]
data newfile(label='Sesame Street Chars');
kermit = 'green';
oscar = 'grouch';
bigbird = 'happy';
run;
[/pre]
Or use a PROC DATASETS MODIFY statement to add a label after the dataset has been created:
[pre]
proc datasets library=work nolist;
modify file2 (label='Notes About Data Go Here');
quit;
[/pre]
When you run PROC CONTENTS, or otherwise examine the data set attributes, you will see the LABEL.
To assign a Label to every variable name, you would use a LABEL statement in the code itself when you create the file OR in PROC DATASETS. For example:
[pre]
data newfile(label='Sesame Street Chars');
kermit = 'green';
oscar = 'grouch';
bigbird = 'happy';
label kermit = 'Kermit the Frog'
oscar = 'Oscar the Grouch'
bigbird = 'Big Bird';
run;
[/pre]
For more information on PROC DATASETS, refer to the documentation. For more information on how SAS labels are used, look for the section in the documentation that talks about SAS variables and attributes of a SAS dataset.
cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, Cynthia!
The dataset label is not as powerful as the STATA notes. According to http://www.stata.com/help.cgi?notes, you can append multiple descriptions to a STATA dataset or a variable.
My boss would like us to have some descriptions built-in with the datasets. Is there a SAS product that self-documents the datasets at least as detailed as STATA does?
Message was edited by: urchin
The dataset label is not as powerful as the STATA notes. According to http://www.stata.com/help.cgi?notes, you can append multiple descriptions to a STATA dataset or a variable.
My boss would like us to have some descriptions built-in with the datasets. Is there a SAS product that self-documents the datasets at least as detailed as STATA does?
Message was edited by: urchin
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
Sorry, I misremembered the length of the label -- it can be up to 256 characters (including blanks) -- for either the dataset label or the variable labels.
It looks that Stata is using the NOTE capability almost as a database descriptor field.
I'm not sure you're going to find that kind of additive note capability in BASE SAS. It seems like this is a difference between Stata and SAS. SAS doesn't have the concept of "codebooks" or "labelbooks" either -- although labelbooks sort of look like SAS formats and DESCRIBE looks like the information from PROC CONTENTS.
Here's some information that I found useful to describe/compare the two different products:
http://sscc.northwestern.edu/docs/sas_stata.cfm
http://www.cpc.unc.edu/services/computer/presentations/sas_to_stata/basic.html
cynthia
Sorry, I misremembered the length of the label -- it can be up to 256 characters (including blanks) -- for either the dataset label or the variable labels.
It looks that Stata is using the NOTE capability almost as a database descriptor field.
I'm not sure you're going to find that kind of additive note capability in BASE SAS. It seems like this is a difference between Stata and SAS. SAS doesn't have the concept of "codebooks" or "labelbooks" either -- although labelbooks sort of look like SAS formats and DESCRIBE looks like the information from PROC CONTENTS.
Here's some information that I found useful to describe/compare the two different products:
http://sscc.northwestern.edu/docs/sas_stata.cfm
http://www.cpc.unc.edu/services/computer/presentations/sas_to_stata/basic.html
cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the original question and answers. I had the same question. A while back someone told me to look at proc datasets for a way to add notes, but now I'm trying it and seeing that it's definitely much less than what Stata has. I found the SAS feature request board so I'll post it there. Thanks!
https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can address this with the long neglected extended attributes, as in:
data class;
set sashelp.class;
run;
proc datasets library=work nolist;
modify class;
xattr add ds note='This is an example of an explanatory notes, which much more possibilities than a dataset label';
quit;
proc contents data=class;
run;
You can also assign extended attributes to individual variables.
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use extended attributes.