Hi,
I have a SAS file A which has no labels. I have another file B in which i have only 2 columns which has values (Column1: All column names in Table 1 and Column2 has all the labels) How to pull the labels which are present as a values from File B and make it as a label in File A.
Hi,
Something like:
data main; a=1234; b=23; run; data labels; var="a"; lab="A label for a"; output; var="b"; lab="A label for b"; output; run; data _null_; set labels end=last; if _n_=1 then call execute('proc datasets nolist lib=work; modify main; label '); call execute(cat(var,'="',strip(lab),'" ')); if last then call execute(';quit;'); run;
Dataset1
Name | Age | Sex | Salary |
Mani | 22 | M | 10000 |
santhosh | 23 | M | 12000 |
karan | 24 | M | 13000 |
vijay | 25 | M | 14000 |
Dataset 2 | |||
col | label | ||
Name | Name of the employee | ||
Age | age of the employee | ||
Sex | sex of the employee | ||
Salary | salary of the employee |
Does it work in the above scenario? i wanna create a Dataset3 which is a copy of dataset 1 with all the labels
Yes, your data looks exactly like the test data I provided above.
Actually, this program does not create Dataset3. Instead, it modifies Dataset1 by adding the labels to it.
Is there any reason you would need two data sets that are identical, except for the labels?
can you alter this and tell me how to create a 3rd dataset and migrate dataset 1 and labels from dataset 2 to the new dataset?
Dataset Name 1:AE
Dataset Name 2: AE_INFO
Dataset Name 3: Test_AE
Colums in AE_INFO= name and label
Very similar tools ... the idea is to generate the proper DATA step:
data _null_;
call execute('data test_ae; set ae; label ');
do until (done);
set ae_info end=done;
call execute(col || '= "' || label || '"');
end;
call execute('; run;');
stop;
run;
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!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.