SAS proc sql pre define format of a variable

15,104

I think that this solves your problem.

select '_NPS' as NPS format=$100. length=100 
Share:
15,104
James Oliver
Author by

James Oliver

Updated on December 01, 2022

Comments

  • James Oliver
    James Oliver 11 months

    I have a table that I am need to create a start point for -the table are changes in NPS. I'm using proc sql to define the value of this.
    The "Kategorie" variable in the table is defined as 100 character long.
    In my proc sql I define the variable as $100, however because I type the value in, it automatically selects a length of 4 and chops off all the data when I blend it with my existing data set.

    So the question is how can I predefine the variable in proc sql so that the length isn't set as 4.
    I have a way to get around this but would rather do it correctly and cleanly.

    rsubmit ;
    proc sql;
    create table NPS_START_overall as select
    '_NPS' as Kategorie format $100.,
    (sum(Promotor)/count(land)-sum(detraktor)/count(land))*100 as RelativeEffect format 8.2
    from erk_a;
    quit;
    endrsubmit;  
    

    I am very much still learning so apologise if this is super basic.
    Thanks

  • fl0r3k
    fl0r3k about 7 years
    Exacly as Jonas wrote. format= will not assign length for a varialbe. You must use length= to do this. There is also label= statement as I remember.
  • Tom
    Tom about 7 years
    Not sure why you need to attach the $100. format to the variable. SAS knows how to print characters variables without attaching formats.