Hi team,
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.
expected outp
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.
Hi,
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.
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:
data temp;
set have;
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 */
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.