BookmarkSubscribeRSS Feed
Jannie_D
Calcite | Level 5
Thank you. That makes sense. But does the code take into consideration that price and date are paired. so only one date-variable match one price-variable and so on? It seems to me that I might need a step for that first?
Kurt_Bremser
Super User

The code works on the strict assumption that date/price variables are paired on their sequence numbers.

Note that because of the use of date: and price:, the order of the variables is important for a correct pairing; see this short illustration of the use of variable lists in ARRAY statements:

data have;
input a1 a2 a3 b1 b3 b2;
datalines;
1 2 3 4 5 6
;

data test;
set have;
array for_a {*} a:;
array for_b_1 {*} b:; /* ordered as positioned in the dataset */
array for_b_2 {*} b1-b3; /* ordered by name */
array for_b_3 {*} b1--b3; /* ordered by position, missing one item */
dim3 = dim(for_b_3);
put dim3;
do i = 1 to 3;
  put i=;
  name_a = vname(for_a{i});
  put name_a=;
  name_b_1 = vname(for_b_1{i});
  put name_b_1=;
  name_b_2 = vname(for_b_2{i});
  put name_b_2=;
  if i le 2
  then do;
    name_b_3 = vname(for_b_3{i});
    put name_b_3=;
  end;
end;
run;

The only method that forces a correct order by variable name, regardless of physical position in the dataset, is the x1-xX notation.

Jannie_D
Calcite | Level 5
It looks like my data set is to big for the proc report statement. It made the program crash a few times. Is there something else I can do instead
Kurt_Bremser
Super User

The fact that you wanted a total sum line for every PNR let me assume you need a report. Inserted summary observations in datasets usually makes those datasets unusable for further processing.

But you can easily summarize from the want dataset:

proc summary data=want;
by pnr notsorted;
var total_cost;
output
  out=sum (drop=_type_ rename=(_freq_=num_years))
  sum()=
;
run;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 18 replies
  • 1478 views
  • 0 likes
  • 4 in conversation