Hi,
I i want to use array to scan cach observation and do a particular calculation if the condition is met...
The condition is that if the data is more than 3 decimals(2 decimals rather) i want to do the calculation 60*60*24
data is like :
10.75 0.41875 19:40 CU-O
When it scans this record only 0.41875 gets the calculation done
19:40 is in the time format(not decimal so no calculation done))
CU-O is some charecter data
Lastly after it does the calculation only those need to be converted into time4. format???
Regards
What is the data type of these variables.
Also give more sample data and the code to read it.
That you want to multiply implies numeric values, however 19:40 is not a numeric value (unless we are seeing the formatted value). This suggests that the incoming values are character and that you want to parse them and convert them to numeric. As DATA _NULL_ said show us what you hope to see as an outcome and especially pay attention to the numeric / character issue.
OK it sounded like fun so. Assuming that all are character and they are to be converted to numeric. Try this:
data have;
length val1-val4 $8;
input val1 val2 val3 val4;
datalines;
0.75 0.41875 19:40 CU-O
0.75 0.41875 19:40 CU-O
1.0 2.22 3.333 xxxx
5 199 12.1212 yyyy
run;
data want;
set have;
array values {3} $ val1-val3;
array nums {3} num1 - num3;
do i = 1 to dim(values);
if index(values{i},':') then nums{i}=input(values{i},hhmmss.);
else if length(scan(values{i},2))>2 then nums{i}=input(values{i},best.)*60*60*24;
else nums{i}=input(values{i},best.);
end;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.