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 is hosting free webinars!
Next up: Joe Madden & Joseph Henry present Putting Power into the Hands of the Programmer with SAS Viya Workbench on Wednesday Nov 6.
Register now 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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 587 views
  • 0 likes
  • 5 in conversation