BookmarkSubscribeRSS Feed
mcook
Quartz | Level 8

I am trying to create a table into the format of the picture below.   specifically the year and percent box layout.  

SasTable.PNG

I have a table like the following.

  HaveTable.PNG

is it possible, with proc print or proc report to transform this table to the format above?

more specifically, Since percent just represents the way that the values should be read, and not really a grouping of the variables by class or group, how do I add it in to the table?  

3 REPLIES 3
ballardw
Super User

Yes.

BUT

Your should really provide some example data that tells where the text values would come from.

 

You don't show where we would get Fall YYYY form at all, only providing a year number. So how do we know if a value comes from Fall or Spring or ...?

How do A,B,C,D etc relate to "Minimal" "Basic" "Passing" "Proficient" etc.

The basic approach would be one of two things: calculate the values and then print, or possibly use Proc report.

You do not state that the "Change in passing" should be calculated between Fall 2015 and Fall 2016 but that is my guess. Which means that a data step might be the best way to calculate and have the values for proc print.

 

But as I said, how do A,B,C relate to the wanted values.

 

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 </> icon or attached as text to show exactly what you have and that we can test code against.

mcook
Quartz | Level 8

Sorry for the long response time.  

I created a dataset similar to what I am working with with datalines.

the relationship between ABCD and minimal, proficient etc isnt important.  I just need the output table to have the same format.  

the following code outputs this table 

HaveTable.PNG

data Test_Table;
	input season Area $ Rating $;
	datalines;
2020 Class A1
2020 Class A2
2020 Class A3
2020 Class A2
2020 Class A1
2020 Class A4
2020 Class A5
2020 Class A5
2020 Class A2
2020 Class A1
2020 Class A2
2020 Class A3
2020 Class A4
2020 Class A5
2020 Class A1
2020 Class A2
2020 Class A4
2020 Class A1
2020 Class A1
2020 Class A1
2020 Class A5
;

proc sql noprint;
	select distinct season 
		into :Ssn
			from Test_Table;
quit;

%put ssn=&ssn.;

proc freq data=Test_Table noprint;
	tables Rating /out=freqtable nocum;
	by Area;
run;

proc transpose data=freqtable out=Percents;
	by Area;
	id Rating;
	var percent;
run;

data Percents (drop=_Name_ _Label_);
	set Percents;
	Year=&Ssn.;
	A6=A3+A4+A5;
	A7=A4+A5;
run;

proc sql noprint;
	create table PercentTable as
		select Year, A1, A2, A3, A4, A5, A6, A7
			from percents;
quit;

proc print data=percenttable noobs;
run;

I need the table in the format of the table in the original post.  With A1-A7 in place of minimal, basic, passing  etc.  

mkeintz
PROC Star

I believe you'll be able to do this in a single PROC REPORT procedure.  But I don't know it well enough to provide useful code.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 766 views
  • 0 likes
  • 3 in conversation