BookmarkSubscribeRSS Feed
vicky07
Quartz | Level 8

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.

4 REPLIES 4
Tom
Super User Tom
Super User

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?

Doc_Duke
Rhodochrosite | Level 12

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.

vicky07
Quartz | Level 8

Doc - Got it. Thanks for the reply!

vicky07
Quartz | Level 8

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 960 views
  • 7 likes
  • 3 in conversation