BookmarkSubscribeRSS Feed
ebowen
Quartz | Level 8

I have a dataset that contains electricity output from a variety of different types of fuels, and I'm grouping them into renewable and non-renewable energy by using a format in PROC TABULATE. I also output the table to a SAS dataset (I've tried this using both the OUT option and ODS). I would like to be able to then subset the table using a data step so I keep only the non-renewable energy and perform a calculation using one of the pieces of data in the output dataset. However, when I try to use a WHERE statement with the name I used for the format "non-renewable," SAS doesn't find any records. Apparently the Tabulate procedure outputs the data using the original source names then applies the format to the output dataset. So when I was looking at it in the results, I could see the records marked non-renewable, but the underlying data still reflects the original source names. That's why I can't find any records under non-renewable, because there is no "non-renewable" source name in the dataset. So that's kind of a long-winded way of asking if there's a way to output the data in such a way that the outputted fields reflect the format labels and not the original data. Thanks in advance for your help!

2 REPLIES 2
Astounding
PROC Star

The data set itself will always contain the unformatted values.  Given your description of what you are trying to accomplish, the easiest way to subset might be to subset the output as part of PROC TABULATE:

... out=my_output_dataset (where=(put(variable, fmtname.)='non-renewable'));

You will still have to figure out what values are in the data set, but at least you'll be working with the proper subset.

Good luck.

ebowen
Quartz | Level 8

Thanks for your answer. I think I may just add another variable to the dataset using a data step and an if statement that includes all of the energy sources that I want in renewable/non-renewable. Then I can use PROC TABULATE to group them by the new variable.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1269 views
  • 1 like
  • 2 in conversation