BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
afiqcjohari
Quartz | Level 8

 

/*Append all table*/
data spay.contactless;
	set usage transactions active ratio;
run;

all the 5 tables above has a variable _NAME_. However when I append them by row as above, the variable _NAME_ has truncated values.

How can I redefine the length for _NAME_?

Or how can I create another variable as below?

/*Combine for Contactless Table*/
data spay.contactless;
  input new_NAME_ $20;
	set spay.usage spay.transactions spay.active spay.ratio;
	new_NAME_ = _NAME_; *copy _NAME_ to new_NAME_;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

SImplest:

 

/*Append all table*/
data spay.contactless;
length _name_ $20; set usage transactions active ratio; run;

 

Just make sure the LENGTH statement appears before the SET statement. 

View solution in original post

3 REPLIES 3
Astounding
PROC Star

SImplest:

 

/*Append all table*/
data spay.contactless;
length _name_ $20; set usage transactions active ratio; run;

 

Just make sure the LENGTH statement appears before the SET statement. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

_NAME_ is a SAS internal variable name which you get from, for example, a transpose output.  Why would you want to be using this further, use your own variables or you might encounter problems later on.  Also, why do you have several sets of the same data which need to be put back together?  If your data is in one dataset - and we have discussed this in one of your other posts - then this question no longer exists.  Your basically just creating blocks of work for yourself needlessly.

ballardw
Super User

If you had read the log after running the step combining the sets you would have seen this message:

 

WARNING: Multiple lengths were specified for the variable _NAME_ by input data set(s). This may cause

truncation of data.

 

Which tells you what the cause was.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 12285 views
  • 1 like
  • 4 in conversation