BookmarkSubscribeRSS Feed
ilikesas
Barite | Level 11

Hi,

 

I am appending data sets using the proc append with the force option, but I notices the following:

 

When I append my first file, the variable "stock" has length $3. Then I append the second file where "stock" has lengh $4, but when it gets appended its length is trimmed to $3 - so does it mean that proc append with the force option "forces" all the subsequent tables' variables' lengths conform to the first table's variables' lengths? Because I thought that when using the force option proc append will choose the longest variable length as the new length in the new base dataset.

If this is so, then how is it possible not to lose variable length?

 

Thank you

2 REPLIES 2
SASKiwi
PROC Star

The documentation states that the attributes of the BASE dataset prevail over the APPEND dataset when using FORCE:

 

http://support.sas.com/documentation/cdl/en/proc/70377/HTML/default/viewer.htm#n19kwc3onglzh2n1l2k4e...

 

Note that to change the attributes of the BASE dataset, it would need to be completely reprocessed which is not how APPEND works in the first place. APPENDs are done without processing the BASE by design.

 

If you want the attributes of the APPEND dataset to prevail use a DATA step SET statement instead with the APPEND table first:

 

data want;
  set APPEND_TABLE
      BASE_TABLE;
run;

 

 

 

Ksharp
Super User

Use SQL insteand.

 

proc sql;
create table want as
 select *
  from one

union all corr

 select *
  from two ;
quit;

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 5341 views
  • 2 likes
  • 3 in conversation