DATA Step, Macro, Functions and more

How to attach a note to a SAS data set, as in STATA the command is "Notes"

Reply
N/A
Posts: 0

How to attach a note to a SAS data set, as in STATA the command is "Notes"

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
SAS Super FREQ
Posts: 8,868

Re: How to attach a note to a SAS data set, as in STATA the command is "Notes"

Posted in reply to deleted_user
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
N/A
Posts: 0

Re: How to attach a note to a SAS data set, as in STATA the command is "Notes"

Posted in reply to Cynthia_sas
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
SAS Super FREQ
Posts: 8,868

Re: How to attach a note to a SAS data set, as in STATA the command is "Notes"

Posted in reply to deleted_user
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
Ask a Question
Discussion stats
  • 3 replies
  • 178 views
  • 0 likes
  • 2 in conversation