DATA Step, Macro, Functions and more

Proc freq-9.2

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,041
Accepted Solution

Proc freq-9.2


Hi Team,

I have a variable with values Y and N . Except that for one observation it is LEV.

I wrote a format as shown below;

value $SER

"Y", "LEV " = "YES"

"N"="NO"

;

RUN;

i apply the format

format variable $ser.

Unfortunately, the LEV stays as LEV and its messing my proc freq!!!!!

I want it to convert to YES

Could anyone help me please???

Thanks


Accepted Solutions
Solution
‎10-20-2012 01:15 AM
Super Contributor
Posts: 543

Re: Proc freq-9.2

Posted in reply to robertrao

Sorry, I had capital "YES" and "Yes".

Try this:

PROC FORMAT;

  VALUE $SER

  "Y" = "Yes"

  "LEV " = "Yes"

  "N"="NO"

;

QUIT;

DATA temp;

  input x $;

  cards;

  Y

  Y

  N

  LEV

  N

  Y

;

PROC FREQ DATA = temp;

  TABLES x;

  FORMAT x $ser.;

RUN;

View solution in original post


All Replies
Super Contributor
Posts: 1,041

Re: Proc freq-9.2

Posted in reply to robertrao

I tried all the options like copy pasting the LEV from the dataset while creating format.

adding spaces to the left and to the right  and so on.doesnt work out!!!!

Super Contributor
Posts: 543

Re: Proc freq-9.2

Posted in reply to robertrao

Hi.

How about this?

PROC FORMAT;

  VALUE $SER

  "Y" = "Yes"

  "LEV " = "YES"

  "N"="NO"

;

QUIT;

Super Contributor
Posts: 1,041

Re: Proc freq-9.2

Posted in reply to AncaTilea

Hi,

Thanks for the reply. It doesnt help...

Thanks

Solution
‎10-20-2012 01:15 AM
Super Contributor
Posts: 543

Re: Proc freq-9.2

Posted in reply to robertrao

Sorry, I had capital "YES" and "Yes".

Try this:

PROC FORMAT;

  VALUE $SER

  "Y" = "Yes"

  "LEV " = "Yes"

  "N"="NO"

;

QUIT;

DATA temp;

  input x $;

  cards;

  Y

  Y

  N

  LEV

  N

  Y

;

PROC FREQ DATA = temp;

  TABLES x;

  FORMAT x $ser.;

RUN;

Super Contributor
Posts: 1,041

Re: Proc freq-9.2

Posted in reply to AncaTilea

This might work fine . But in My situation I do not understand how LEV is written.

Do youi recommend removing leading and trailing spaces if any///////////????

Could you show me how to acheive that?

Thanks

Super Contributor
Posts: 543

Re: Proc freq-9.2

Posted in reply to robertrao

Say, one way would be to use the compress function on your variable:

data temp2;

  set temp;

/*remove blanks*/

           z = compress(x);

  format z $ser.;

run;

proc freq data = temp2;

  tables z;

run;

Super Contributor
Posts: 1,041

Re: Proc freq-9.2

Posted in reply to AncaTilea

Hey Thanks a ton;

I decided to see what its length is and put so many trailing blanks. and went to see the attributes.

Its displayed as "LEV" in the dataset but when i pull using IN option(filtering on the editor) to see the different types I found it with the full form..

LEVEL. So I put "LEVEL"="YES" in my format immediately and it worked.

Thanks for your time.

Great Help

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 295 views
  • 3 likes
  • 2 in conversation