11-10-2015 09:56 AM
I am working with 3 sas datasets each of which have 2 identically named variables e.g txtcmmnt. One of them has a label and the other doesn't. When I use a keep option it only shows one variable but a proc contents or a veiw of the datasets it shows the 2 variables. I need to stack the 3 datasets into a final sas dataset . I would like to delete the variable with no label. How should I do it? Any suggestions will be helpful.
11-10-2015 10:00 AM
11-10-2015 10:00 AM
11-10-2015 10:06 AM
I thought the same so I did a proc content to carefully check the spellings:
This is an example of what shows up in the proc contents:
Variable Type Length Format Informat Label
Txtcmmnt Char 1754 1. Is there anything you would like to add?
Txtcmmnt Char 146 $146
Its the second one with no label that I would like to delete.
11-10-2015 10:17 AM
As Jagadishkatam has metioned, you cannot have two separate columns, which have the same name in one dataset. Its not possible within SAS. Can you provide example data?
If you stack data, then it should keep the properties of the first dataset:
data tmp; label a="Hello"; a="Abc"; run; data tmp2; a="Def"; run; data final; set tmp tmp2; run;
One way you could force it is to use SQL, with union all, and specify the labels in the first select:
proc sql; create table FINAL as select VARA label="xyz" from TMP union all select * from TMP2 union all... quit;
11-10-2015 10:36 AM
I agree with both of you. I checked the spellings of the variables . There is uppercase 'I' and looked to see if it is a '1' and it is not. The thing is when I try to stack the datasets , inspite of getting the lengths uniform on the variable txtcmmnt it gives me a warning message:
WARNING: Multiple lengths were specified for the variable txtCmmnt by input data set(s). This can cause
truncation of data
The new lengths get applied only to the variable with the label. Have you come across something like this? Also, @RW9, the dataset looks like this
11-10-2015 10:40 AM
Try opening the properties of the two datasets. What you are showing below doesn't really show anything. I suspect the two variables have the same LABEL, but the variable NAME is different. Run a proc contents of each one, or right click on the file and select properties.
Need further help from the community? Please ask a new question.