Hi,
I'm using proc append inside a macro and having variable length issues. Below is my code
%Macro ass(dat);
Proc Append base = combine data = &dat. Force;
Run;
%Mend;
%dat(data1);
%dat(data2);
%dat(data3);
%dat(data4);
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.
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?
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.
Doc - Got it. Thanks for the reply!
Tom,
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.