The SAS Output Delivery System and reporting techniques

how to generate customised report with certain conditions in sas 9.3

Reply
New Contributor
Posts: 2

how to generate customised report with certain conditions in sas 9.3

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.

 

Esteemed Advisor
Esteemed Advisor
Posts: 6,710

Re: how to generate customised report with certain conditions in sas 9.3

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.

Super User
Posts: 1,078

Re: how to generate customised report with certain conditions in sas 9.3

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;

Post a Question
Discussion Stats
  • 2 replies
  • 180 views
  • 0 likes
  • 3 in conversation