BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Sathya3
Obsidian | Level 7
%let source = other_rfb; /* Example value for the macro variable */

data glow;
input id $ source $ class $ country $;
datalines;
11e other mid au
23 other_rfb large eu
123ab other small other in
;
run;

data glow2;
set glow;
length id $200;
if "&source" in ("other", "other_rfb") then do;
id = class || "_under_250k" || country;
end;
else do;
id = class || "_under_250k";
end;

run;

Concatenation is not happening for id coulmn .id just has class values in glow2 dataset. Can you please help with correct code. Tried with cats as well

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Please read the log, it tells you what the problem is.

 

45    data glow2;
46    set glow;
47    length id $200;
WARNING: Length of character variable id has already been set.
         Use the LENGTH statement as the very first statement in the DATA STEP to declare the length of a character variable.
48    if "&source" in ("other", "other_rfb") then do;
49    id = class || "_under_250k" || country;
50    end;
51    else do;
52    id = class || "_under_250k";
53    end;
54
55    run;

 

Your LENGTH statement didn't do anything where it is located. The LOG even tells you how to fix it.

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

Please read the log, it tells you what the problem is.

 

45    data glow2;
46    set glow;
47    length id $200;
WARNING: Length of character variable id has already been set.
         Use the LENGTH statement as the very first statement in the DATA STEP to declare the length of a character variable.
48    if "&source" in ("other", "other_rfb") then do;
49    id = class || "_under_250k" || country;
50    end;
51    else do;
52    id = class || "_under_250k";
53    end;
54
55    run;

 

Your LENGTH statement didn't do anything where it is located. The LOG even tells you how to fix it.

--
Paige Miller

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 116 views
  • 2 likes
  • 2 in conversation