BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
75063
Obsidian | Level 7

Hi, 

 

I am trying to summarize the data (sample data attached) in the attached sample template with proc report. However I am getting error message  after I write this code 

 

proc report data=sample

out=lat nowd;

column FT TERM_DESC work  let2015 ;

define FT/group;

define TERM_DESC/ ACROSS ;

compute let2015;

if TERM_DESC = "Fall 2016" THEN let2015 = work.sum ;

endcomp;

quit;

 

 

The error message states - Variable TERM_DESC is uninitialized.

 

Will appreciate some guidance in moving ahead and any tips to overcome any future hurdles in the report.  

 

Thanking you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Per the topic here:

https://communities.sas.com/t5/Base-SAS-Programming/template/m-p/486193/highlight/false#M126458

 

Use a datastep and transposes before proc report to manipulate your data, then use a simple proc report to output the data.  This is far simpler and more effective method than using a reporting procedure to manipulate data.

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Per the topic here:

https://communities.sas.com/t5/Base-SAS-Programming/template/m-p/486193/highlight/false#M126458

 

Use a datastep and transposes before proc report to manipulate your data, then use a simple proc report to output the data.  This is far simpler and more effective method than using a reporting procedure to manipulate data.

75063
Obsidian | Level 7
Should I summarize the data in the Data step and then TRANSPOSE. BY doing something like this -

Data Sad;
Set UNIVERSI.univ2016_17;
if TERM_DESC= "Fall 2016" then NEWVAR = SUM(work);
else if TERM_DESC="Fall 2017" then NVAR = SUM(work);
Run;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Without seeing your data I have no idea.  You are effectively doing that in the proc report though, so just a matter of doing it in a datastep.  sum() function does not work the way you think, it works horizontally, so sum(work) will be the same as work, same number of observations.  You would need to retain it across rows:

data sad;
  set...;
  retain newvar nvar;
  if...;
run;
75063
Obsidian | Level 7

Thank you for your reply. I have attached the Dataset and the reporting template here. Can you please advice the most efficient way to go about this.    

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!

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.

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
  • 4 replies
  • 910 views
  • 2 likes
  • 2 in conversation