BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
7 REPLIES 7
Cynthia_sas
SAS Super FREQ
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
deleted_user
Not applicable
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
Cynthia_sas
SAS Super FREQ
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
MattJans
Obsidian | Level 7

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 

mkeintz
PROC Star

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

--------------------------

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2708 views
  • 6 likes
  • 5 in conversation