OBS Value change

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 86
Accepted Solution

OBS Value change

Hi,

If i have  a 1000 obs like this

INDIA          1000000

USA              10000

Canada     10000

UK               1000

How do i change it to like this

Delhi         1000000

Alabama    10000

Torento    10000

London      1000


Accepted Solutions
Solution
‎08-24-2012 04:11 PM
PROC Star
Posts: 7,474

Re: OBS Value change

That in essence would change it in your dataset but, since such changes are not reversable, I did it to a copy of your dataset.

There is nothing stopping one from using the same file in both the data and set statements.  e.g.:

data have;

  set have;

  place=put(place,$place.);

run;

However, it is not a recommended practice (i.e., don't complain if you end up losing your original dataset)!

View solution in original post


All Replies
PROC Star
Posts: 7,474

Re: OBS Value change

How about proc format?  e.g.,

proc format;

  value  $place

  "INDIA"="Delhi"

  "USA"="Alabama"

  "Canada"="Toronto"

  "UK"="London"

;

run;

data have;

  input place $ score;

  cards;

INDIA          1000000

USA              10000

Canada     10000

UK               1000

;

data want;

  set have;

  place=put(place,$place.);

run;

Frequent Contributor
Posts: 86

Re: OBS Value change

Thx Arthur but i need this change should be happen in my data set not on the out put (Proc report, proc format)

Super Contributor
Posts: 1,636

Re: OBS Value change

proc format;

  value  $place

  "INDIA"="Delhi"

  "USA"="Alabama"

  "Canada"="Toronto"

  "UK"="London"

;

run;

data have;

  input place $ score;

  cards;

INDIA          1000000

USA              10000

Canada     10000

UK               1000

;

data want;

new_place $ 10;

  set have;

  new_place=put(place,$place.);

run;

proc print;run;

Solution
‎08-24-2012 04:11 PM
PROC Star
Posts: 7,474

Re: OBS Value change

That in essence would change it in your dataset but, since such changes are not reversable, I did it to a copy of your dataset.

There is nothing stopping one from using the same file in both the data and set statements.  e.g.:

data have;

  set have;

  place=put(place,$place.);

run;

However, it is not a recommended practice (i.e., don't complain if you end up losing your original dataset)!

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 228 views
  • 3 likes
  • 3 in conversation