04-28-2016 10:00 PM
Hi, Is there any way to use lable name instead of varaible name in data step processing ?
Name = 'Jon' label first_name;
if first_name = 'Jon';
04-28-2016 11:36 PM
OK. Here is an example.
data class; set sashelp.class; label sex='Sex FM' name='NAME' age='P AGE'; keep sex name age; run; proc transpose data=class(obs=0) out=temp; var _all_; run; options validvarname=any; data _null_; set temp end=last; if _n_ eq 1 then call execute(catt('proc datasets library=work nolist nodetails;modify class;rename ')); call execute(catt(_name_,'=',nliteral(_label_))); if last then call execute(';quit;'); run;
04-29-2016 09:51 AM
We have to use another team’s DataMart for our processing. We don’t have control on creation of DataMart but we know this DataMart is created by fetching records from Teradata tables. We also use same tables and our most of code is written by using variable name from these tables. Somehow we have to use this DataMart (created by another team) as source for all our code. The problem is team has used alias for most of variables but label is still same as variable name from Teradata tables. Now the only option for us is to use these alias instead of variable name in our code but it’s really tedious to make all the changes.
Is there any way where we can use this DataMart in our code ? We have to use this DataMart so no option to create another DataMart with same name as Teradata tables.
04-29-2016 10:47 AM - edited 04-29-2016 10:50 AM
Is there a table anywhere that links the alias to the "full value" you need? It may be possible to link the information in a useful manner. Possibly using Proc Datasets to assign the longer value as labels and rename variables (or vice versa, I'm not quite clear on your requirement).
Or if you have list of your current variables and labels and the datamart variables and labels match those up to create a your variable to their variable list and then use proc datasets to rename your variables.
I've actually done this to include modifying code files to change the variable names.
Provide a bit more explicit example of what is going on, whay you get from the datamart, what you have, what needs to change.
04-29-2016 01:35 PM
Sorry for not being clear on my requirement.
Here is what is our requirement and what we have.
*** Existing DataMart creation by another team ***;
Connect Teradata ;
Create table test_Datamart as
Select first_name as fName
Last_name as lname
Connect Teradata ;
Create table test as
Where first_name = ‘Jon’;
As per change , we need to use “test_Datamart” in our code instead of “test” data. the problem is “test_Datamart” using alias for all variable name and you can see first_name is fname. So we need to make changes to our code to reflect alias name instead of actual variable name.
This is just one example. In real scenario , there are almost 100 variables in “test_Datamart” and we have almost 25+ codes that now need to change to reflect alias name. I know that label for all these variables in “test_Datamart” is same as actual variable name of tables in Teradata. I just want to know if there is any option to define in any system options or any dataset options so it would take label as variable name in dataset processing.
Data test1 label;
Set test_Datamart; *** this dataset renamed first_name to fname but label is still showing first_name.
Where first_name = ‘Jon’; *** I want to use first_name in my code but there is no variable called “first_name “ in test_Datamart.