Dear,
in my raw data, a variable value contains characters longer than 200 characters in length. I need split the value into variable1, variable2, and so on depends on the number of charracters and each variable can contain maximum of 200 characters. Thank you.
data
Variable
Site to document the deviation in the subject source. Sleep technician will receive addition protocol training for scoring requirements and procedures. Site reported the deviation to the investigator on 20JUN2013.Subject 32 Screening Mean sleep latency could not be determined for this subject as sleep latency was unknown for all of the MWT naps.
Here's a recently asked question that only splits into 2 variables instead of 3 ... but all the same techniques would apply.
You may try:
length var1-var5 $200; /* assume max 5 variables to output */
array varx var1-var5;
var_len = length(var_in);
do i=1 to 5; varx(i)=' '; end;
if var_len le 200 then var1 = var_in;
else do ;
i=1;
do until (var_len < 200);
varx(i) = substr(var_in,(i-1)*200 +1, min(var_len, 200));
var_len = var_len - 200;
i+1;
end;
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.
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.