![]() Here are how our DEMO table looks before and after %ilabel macro modifies/assigns the labels based on the column names: You can invoke this macro by either one line of code: * modify variable labels */ proc datasets lib= &lbref nolist Lbl = propcase ( translate (name, ' ', '_' ) ) Ĭall symput ( 'vlabel'!!strip ( put ( _n_,best. * create name/label pairs */ data _null_ Ĭall symput ( 'vname'!!strip ( put ( _n_,best. * get variable names */ proc contents data= &dataset out=_data_ ( keep=name ) noprint %else %do /* 1-level dataset name */ %let lbref = WORK %let dsname = %scan ( &dataset, 2, '.' ) ) %then %do /* 2-level dataset name */ %let lbref = %scan ( &dataset, 1, '.' ) Let’s say our original data table is DEMO: These are the labels we will get: Customer Address, First Name, Last Name, Company Name, Place Of Birth. We can transform these names into labels by replacing underscores with space characters and converting words from upper case to proper case. This method is suitable when variable names are well-formed, for example CUSTOMER_ADDRESS, FIRST_NAME, LAST_NAME, COMPANY_NAME, PLACE_OF_BIRTH, etc. Deriving variable labels from variable names Plus, we are going to explore SAS coding technique using _DATA_and_LAST_special data sets. Let’s look into one of them that I found useful for bulk column labeling, especially in quick turnaround scenarios like developing an analytics proof of concept (PoC). However, in many situations there are ways of automating this tedious and voluminous process of column labels creation. Alternatively, you can do it after your data table is already created by using PROC DATASETS’ MODIFY statement with the LABEL= option. You can do it during the data table creation in a DATA step using either LABEL statement or ATTRIB statement. The most direct way of creating column labels is by explicitly assigning them to the data variables. ![]() Besides being more efficient, such an early label assignment secures consistency of the data elements descriptions (labels) across different developers. Whether you use SAS data table as a data source in any of the reporting procedures or interactive interface such as SAS Visual Analytics, you will benefit from pre-assigning meaningful labels during the data preparation process. SAS variable labels are unique features of SAS data tables (aka data sets) that allow SAS users to enhance reading and interpretation of tables and reports.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |