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 ;

 

BASUG is hosting free webinars Next up: Mike Raithel presenting on validating data files on Wednesday July 17. Register now at the Boston Area SAS Users Group event page: 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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 415 views
  • 0 likes
  • 5 in conversation