BookmarkSubscribeRSS Feed
mani0211
Calcite | Level 5

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.

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;
mani0211
Calcite | Level 5

 

 

Dataset1

 

NameAgeSexSalary
Mani22M10000
santhosh23M12000
karan24M13000
vijay25M14000
    
 Dataset 2   
collabel  
NameName of the employee
Ageage of the employee
Sexsex of the employee
Salarysalary 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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes, your data looks exactly like the test data I provided above.

Astounding
Opal | Level 21

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?

mani0211
Calcite | Level 5

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

Astounding
Opal | Level 21

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;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1076 views
  • 0 likes
  • 3 in conversation