BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Thalitacosta
Obsidian | Level 7

I have a macro that creates several tables "ks1", "ks2", .... I use the "proc append" to join all these tables, but there is a different length from the variable "_var_" in each table, so the "ks_end" table does not return the observations of the tables that the length of "_var_" is greater than "ks1". How to determine in "proc npar1way" a default length for "_var_"? Here's part of the code:

 

proc npar1way data=sort_&score0. noprint;
class &perf.;
var &score0.;
output out=ks1&k. (rename=(_d_=ks)) edf;
run;

 

proc append data=ks&k. base=ks_end;run;

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
proc npar1way data=sort_&score0 noprint;
    class &perf;
    var &score0;
    output out=ks1&k (rename=(_d_=ks)) edf;
run;
data ks1&k;
    length _var_ $ 256;
    set ks1&k;
run;
proc append data=ks&k base=ks_end;
run;
--
Paige Miller

View solution in original post

2 REPLIES 2
ballardw
Super User

Which specific variables are involved? If, as I suspect, they are either your CLASS or VAR variables hidden by those macro variables the solution will be make sure that when you create the input data sets Sort_&score0 that the variables have the same length.

 

I strongly suspect you are relying on either Proc Import or another approach to bring data into SAS that defaults to setting the lengths of variables to different lengths for different variables. If you want to append these variables to a data set then make sure that one of the following is done:

Either make sure that the data when read has all variables with the same length or

1) the very first data set has the longest lengths set for all the variables and 2) use the FORCE option to allow the append to take place.

PaigeMiller
Diamond | Level 26
proc npar1way data=sort_&score0 noprint;
    class &perf;
    var &score0;
    output out=ks1&k (rename=(_d_=ks)) edf;
run;
data ks1&k;
    length _var_ $ 256;
    set ks1&k;
run;
proc append data=ks&k base=ks_end;
run;
--
Paige Miller

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 1146 views
  • 4 likes
  • 3 in conversation