BookmarkSubscribeRSS Feed
raajdesaii
Fluorite | Level 6

Hi guys,

 

How can I avoid the truncation of the data in the data steps(merge the datasets) of the loop?

 

The warnings show:

 

WARNING: Multiple lengths were specified for the variable "....." by input data set(s). This can cause truncation of data.

 

The code is:

 

data raj.brfssfinal;

set raj.brfss11 raj.brfss12 raj.brfss13 raj.brfss14
raj.brfss15 raj.brfss16;
run;

 

Out of all those datasets, only brfss16 has a variable seqno which is a character variable and therefore, it gives me an error: ERROR: Variable seqno has been defined as both character and numeric!! 

 

When I change the character variable in the raj.brfss16 dataset to numerical variable, then it gives me trauncation error for multiple other variable except seqno. I am not sure where am I going wrong.

 

Please help me out with this.

 

Thanks! 

4 REPLIES 4
Kurt_Bremser
Super User

If you get those datasets from external sources, you need to correct all this in the steps that read the data, and your issues will disappear on their own.

raajdesaii
Fluorite | Level 6

So by that do you mean convert the variables to either numeric or character in the steps that read the data? 

 

I tried doing that and it still would not work. 

Kurt_Bremser
Super User

You don't convert, you correct the input and other statements that set variable attributes. Note that you do NOT use proc import in such situations, you use one data step to read all infiles.

ballardw
Super User

To have a variable like SEQNO as both character and numeric means that in at least one program where you read the data you created the variable as character.

 

You might find this bit of code useful for summarizing the characteristics of your variables in the given data sets.

The 1 in the results columns basically serves to indicate which year of your data has the characteristics of the variables that will be the row headers.

Proc tabulate data=sashelp.vcolumn;
   where libname='RAJ' and 
         memname in ('BRFSS11' 'BRFSS12' 'BRFSS13' 'BRFSS14');
   class memname name type length;
   table name*type* length,
         memname
         /misstext=' '
   ;
run;

And depending on how much your organization does with standardizing BRFSS data variables you a very likely to have question numbers from the survey from different years with different ranges of values not just the occasional change from numeric to character caused by your read program(s).

 

 

I have worked with BRFSS data from collection to reporting in a number of roles since 1998 and have used the data back to 1984. So have developed tools, such as the tabulate above, to summarize the metadata.

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