12-13-2016 07:20 AM
My inputa dat set is as below mentioned in sas code:
So input data set contains amt column as character data type(as it is having both numeric and character values)
but in final report i want to show numeric rows of column amt as numeric with some format and charcater rows as character.
data tmp; name="megha"; amt="17000000.03"; flg="N"; output; name="Alok"; amt="12200000.04"; flg="N"; output; name="Bittu"; amt="Bit"; flg="C"; output; name="Cittu"; amt="Cit"; flg="C"; output; run;
ut is attached in excel sheet.
12-13-2016 07:52 AM
I am afraid it is unsafe to download office files, so I can't see your output. If you want to see mixed formats in one column in your output,then the simplest way is to create a character field to hold all the data, and then set each of your data items into that, for example:
data want; set have; length output_column $50; output_column=put(number_var,z5.); output; output_column=text_variable; output; output_column=put(date_variable,date9.); output; ... run;
So in each case I take a variable, convert it to text (if needed) and store the result in output_column. Then that output column can be displayed in your report. In SAS (as with all structured data) you cannot have a column with mixed types, but text kind of covers everything.
12-13-2016 08:05 AM
You better split the amt variable into two variables: amt_n for numeric and amt_c for alphanumeric.
If you can't do it on yout input then you can do it like:
length amt_n 8 amt_c $8; /* adapt length to max number of characters */
if indexc(locase(amt),'abcdefghijklmnopqrstuvwxyz') > 0
then amt_c = amt;
else amt_n = input(amt, best 12.2); /* addapt informat as needed */