DATA Step, Macro, Functions and more

set several data set together with cut off variable

Reply
Frequent Contributor
Frequent Contributor
Posts: 78

set several data set together with cut off variable

[ Edited ]

Dear all,

 

I tried to combine several data together by using set statement.  

 

Thought I ues length statement to set up the "var_level " as  $ 100 .  However , the var_level was still trucated. 

 

Any solution ?  Thank you very much !    (The length is enough to cover the var_level at each file. , no error message. )

 

Ivy 

 

 data rpt_cat;
length var_level $ 100. ;
set rpt_gender  

rpt_uidxinsplan ;
run;

 

3218 data rpt_cat;
3219 length var_level $ 100. ;
3220 set rpt_gender rpt_uidxinsplan ;
3221 run;

NOTE: There were 3 observations read from the data set WORK.RPT_GENDER.
NOTE: There were 14 observations read from the data set WORK.RPT_UIDXINSPLAN.
NOTE: The data set WORK.RPT_CAT has 17 observations and 7 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

 


Original_f.PNG
Super User
Posts: 19,768

Re: set several data set together with cut off variable

Please post code used. 

Make sure you put length statement before the SET statement. 

Super User
Posts: 5,496

Re: set several data set together with cut off variable

Most likely, the variable also has a format attached to it that is truncating the displayed value.  Add the FORMAT statement AFTER the SET statement, to remove the format:

 

format var_level;

 

Good luck.

Trusted Advisor
Posts: 1,117

Re: set several data set together with cut off variable

[ Edited ]

Edit: I see, @Astounding was faster and had the same idea.

 

Hello @Ivy,

 

The reason for the truncation may be a format (such as $17.) which is permanently associated with variable VAR_LEVEL. This would be shown in column "Format" of the PROC CONTENTS output for dataset RPT_CAT. You could get rid of this format by adding the following statement before the run; in your data step:

format var_level;

 

Frequent Contributor
Frequent Contributor
Posts: 78

Re: set several data set together with cut off variable

Posted in reply to FreelanceReinhard

Thank you very much ,

 

 Removing format works beautifully !

 

 

Ask a Question
Discussion stats
  • 4 replies
  • 249 views
  • 0 likes
  • 4 in conversation