03-13-2012 06:57 PM
I'm using proc append inside a macro and having variable length issues. Below is my code
Proc Append base = combine data = &dat. Force;
I have 3 variables in all the 4 datasets (Name, City, Balance) and the length of Name and City are different in each one those datasets. Now while appending it is truncating the extra length in dataset 2,3& 4. Is there a way to append the datasets without truncating the Name and City values?
Thanks in advance for your help.
03-13-2012 07:10 PM
You need to create the base dataset (COMBINE in your code) with variables long enough so that when the others are appended the data is not truncated.
Why are the datasets in different formats?
And since they are in different formats why are you appending them?
03-13-2012 07:30 PM
Tom's right on what needs to be done.
Often, when we get data from different providers, the lengths of text fields are different. One of the beauties of SAS is that it can handle data like that.
Vicky, if 'combine' already exists, you can use a data step to replace it with an new version that changes the lengths of name and city. You can also use a data step to create the data set 'combine' with no observations.
03-13-2012 08:05 PM
The reason for different length is the datsets are created by different users and I need to append all of them as one dateset and upload it to a server. I can use data & set steps along with length statements to combine but the problem is the number of datsets that I get might vary, like sometimes I can set 10 and some times just 4. So i thought append will be easier to handle instead of data&set statements.
Creating an empty datasets with variables long enough make sense. Thanks for the solution.