turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Re: proc means

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-15-2018 02:56 PM

I have a numeric variable which includes some written characteristics parts like the following

the problem is I need to calculate some statistics for the variable by proc mean and it doesn't let me bc of the written characteristic part. this is the error that I got

Variable site_number in list does not match type prescribed for this list

I need a way to ask sas to ignore the written part and just calculate the numeric

or substr the numeric part

1453 |

1500 |

1600 |

1601 |

1602 |

1700 |

1750 |

5000 |

5002 |

5003 Main Campus |

5003 Burbank |

Accepted Solutions

Highlighted
## Re: proc means

Options

Solution

02-16-2018
11:41 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to mona4u

02-15-2018 03:19 PM

PROC MEANS does not compute statistics for character variables. You need to create a new variable, make it numeric, and have it contain the numeric piece of SITE_NUMBER. For example:

data want;

set have;

newvar = input( compress(site_number, , 'kd' ), 5.);

run;

Then you can process the new variable with PROC MEANS.

If the numeric portion is always the first four or five characters of SITE_NUMBER, the formula can be simplified:

newvar = input(site_number, 5.);

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to mona4u

02-15-2018 02:59 PM

filter using

`where anyalpha(var)=0;`

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to novinosrin

02-15-2018 03:04 PM

this code isn't working

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to mona4u

02-15-2018 03:05 PM

post your code and log please

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to mona4u

02-15-2018 06:23 PM

mona4u wrote:

this code isn't working

Doesn't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

Highlighted
## Re: proc means

Options

Solution

02-16-2018
11:41 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to mona4u

02-15-2018 03:19 PM

PROC MEANS does not compute statistics for character variables. You need to create a new variable, make it numeric, and have it contain the numeric piece of SITE_NUMBER. For example:

data want;

set have;

newvar = input( compress(site_number, , 'kd' ), 5.);

run;

Then you can process the new variable with PROC MEANS.

If the numeric portion is always the first four or five characters of SITE_NUMBER, the formula can be simplified:

newvar = input(site_number, 5.);

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to mona4u

02-15-2018 03:49 PM

You need to clean your data before you analyze it. With the data in the form shown, I suspect it was not read in correctly to start.