Help using Base SAS procedures

Proc Append

Reply
Contributor
Posts: 71

Proc Append

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.

Super User
Super User
Posts: 6,502

Proc Append

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?

Trusted Advisor
Posts: 2,113

Proc Append

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.

Contributor
Posts: 71

Proc Append

Doc - Got it. Thanks for the reply!

Contributor
Posts: 71

Proc Append

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.

Ask a Question
Discussion stats
  • 4 replies
  • 260 views
  • 7 likes
  • 3 in conversation