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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.