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

/* When I run the following PC SAS program, all the id’s are summarized into the first id, which is wrong. */

data test;

input @ 1 id 15.

@17 amt 1.

;

cards;

098022134104033 1

098022134104033 2

098022134433892 3

098022134433892 4

;

run;

proc summary data=test nway;

class id;

var amt;

output out=test1(drop=_type_ _freq_) sum=;

run;

proc print data=test1;

format id z15.;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Warren
Obsidian | Level 7

I got the following answer from SAS Technical Support:

You need to apply a format in advance to the ID variable as PROC SUMMARY is using BEST12. behind the scenes.

 

Example:

 

data test;

      input @ 1 id 15.

              @17 amt 1.

              ;

format id z15.;

cards;

...

View solution in original post

3 REPLIES 3
Warren
Obsidian | Level 7

I got the following answer from SAS Technical Support:

You need to apply a format in advance to the ID variable as PROC SUMMARY is using BEST12. behind the scenes.

 

Example:

 

data test;

      input @ 1 id 15.

              @17 amt 1.

              ;

format id z15.;

cards;

...

ballardw
Super User

Note that ability to assign variables to groups by use of a format is a very powerful tool in SAS. For example if you have SAS date values you can get summaries by Year, Year and Month, Month, Day of month, Day of year (1-365), Calendar quarter, Year and calendar quarter, day of the week, and week of the year by using a different format for the same variable.

 

And most of the analysis procedures will group values accordingly.

Reeza
Super User

It's a good idea to keep ID fields as character fields for this reason. 

 

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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