Hi All,
I have a column (V_04) in a table, which is character. It has both charater values as well numberic values.
I want to print the values in excel for that coulmn in two different formats, for character value it should be $50. and numeric value it should be commax12.2 format.
I have used the below code. but it is not giving the expected value, that is commax12.2
compute V_04;
If FMT="N" then do;
call define(_COL_,'format','commax12.2');
end;
else do;
call define(_COL_,'format','$50.');
end;
endcomp;
Could you help me to solve this issue.
Thanks you.
Regards,
Alex
You cannot apply a numerical format to a character variable.
I suggest to convert prior to printing:
if FMT = 'N' then V_04 = put(input(V_04,best.),commax12.2);
Then V_04 can simply be printed as is.
Edit: corrected mistake about _COL_
In any structured environment, columns are treated as all retaining the same format. Unfortunately Excel is not a structured enironment. The question is, do you really want mixed formats in one column - from a programmers point of view the response is no. Reformat your output so that each column has a consistent format.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.