BookmarkSubscribeRSS Feed
sfarash
Calcite | Level 5

I ran this code:

 

data dir.ENGBase;

length s2_disability_0_5_other $38;

set dir.E1;

run;

 

Goal is to change the length of s2_disability_0_5_other from a length of 7  in the set dir.E1 to 38 characters in the set dir.ENGBase. 

 

When I run the code above, the length doesn’t change in the new dataset ENGBase. It still shows as length 7

 

Can you help me understand what I’m doing wrong? 

 

I have a long list of char variables in E1 whose length I need to increase in the output ENGBase to accommodate a future append of multiple datasets max lengths. I already determined what the max length needs to be in the first dataset so that no truncation happens. 

 

Any suggestions on how to get the lengths to increase in the base dataset?

 

I tried it with and without the "." after the length number 38.  Neither worked.

4 REPLIES 4
Quentin
Super User

Your code looks good to me.  Double check the log, do you get any errors/warnings/bad notes?

 

I ran a modified version of your code and it worked fine:

 

data E1 ;
  length s2_disability_0_5_other $7;
  s2_disability_0_5_other="Q" ;
run ;

data ENGBase;
  length s2_disability_0_5_other $38;
  set E1;
run;

proc contents data=E1 ;
run ;

proc contents data=ENGBase ;
run ;

 

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
ballardw
Super User

Did the log show anything entertaining? It might help to show us the Log from when you ran the code.

 

Is the variable s2_disability_0_5_other in column 1? (you can check with contents or opening the data set) If not, then you are likely dealing with a failure to replace an existing data set for some reason, or something else overwriting the set.

Kurt_Bremser
Super User

Do not confuse the storage LENGTH of a variable with the width of a FORMAT assigned to it. If the variable also has a format of $7. assigned to it, you won't see more than 7 characters.

PaigeMiller
Diamond | Level 26

Please show us PROC CONTENTS output for variable s2_disability_0_5_other in data set dir.ENGBase. And as requested by others, also show us the full log for this DATA step.

--
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
  • 4 replies
  • 550 views
  • 0 likes
  • 5 in conversation