BookmarkSubscribeRSS Feed
ErikLund_Jensen
Rhodochrosite | Level 12

Back to your question after these editorial exercises... 

 

First: The data step you posted as source for data set weightclub produces numeric variables. So @Astounding is right about the cause of your log errors: your input data was created by a different program. If you run the data step in your post from yesterday first and then the data/tablulate step, you don't get the errors.

 

Second: @stat_sas  pointed out that you should use a star instead of a comma in your Proc Tabulate.

not: table team,(StartWeight EndWeight),mean;

but: table team,(StartWeight EndWeight)*mean;

The star gives you the wanted statistic, while the comma adds an extra dimension and produces 2 useless tables. But it works and does not cause errors in the log.

 

Third: As @Patrick pointed out, you omitted a run statement before Proc Tabulate. Data steps and Proc steps are two different things, you cannot use a proc statement inside a data step, so you need to terminate the Data step before continuing your program with a Proc step. Your run statement is terminating the Proc Tabulate step, not the Data step. However, any Proc xx or Data statement acts as an implicit termination of the preceding step, so this omission does not cause any errors, but is generally seen as sloppy coding.

 

Conclusion: Your program runs without errors, if you use the right input, But it needs the correction proposed by sas_stats to give the desired output. And please help yourself (and others reading your code) by always using an explicit step termination. Good luck with the weight club.

mdoddala
Obsidian | Level 7

Thank you @ErikLund_Jensen for your clear explanation:) I think I did the mistake and I was not connecting the right dataset. Thanks again for being patient with me! I'm a beginner programmer in SAS.  

ErikLund_Jensen
Rhodochrosite | Level 12

@mdoddala 

 

We all started as beginners, so don't let that trouble you. I know it is difficult, because SAS is not like other tools on your PC. SAS is old. A few core technologies may have survived, but SAS is probably the one and only end user tool that has been with us since data processing meant MVS systems with card punchers for input and line printers for output. I remember writing a SAS program when somebody came to tell me that Ronald Reagan had beaten Carter, and it is a marvel that a platform is still readily available to run that program today.

 

SAS was easier to learn in those days. In the beginning was the Data Step and a few procedures, but SAS evolved and expanded to cover new technologies. Display Manager came with CRT terminals, SAS Macro language arrived to add a scripting language to SAS, with relational databases came ODBC, SQL came as the new highlight of end-user query tools and was added to SAS also, New presentation technologies found their way into SAS with the Output Delivery System and so on. Now SAS VIYA has arrived and will over time relegate people like me to dinosaurs, but that is another story.

 

As an old SAS hand one had a lifetime to adopt to all these new possibilities, but a new user today will get the whole package with tools an tiers and metadata and what not. It is like a whole world of its own, and no single person can be an expert in all parts of it, but SAS version 9 is still based on the good old principles, the core is a batch system, and all SAS applications from Display Manager to SAS Studio are just interfaces that helps the user to write a program, submit it to processing in background and retrive the result.

 

This makes SAS stand apart from most applications that interact with a database. SAS does not handle transactions, but whole files and data sets, and this concept is difficult to comprehend for a Java or Visual Studio programmer. It is a different way of thinking, and an understanding of the concept of steps as separate blocks connected only via data files or -sets is necessary together with knowledge of the language elements and the way SAS handles a program, just as knowing the principles of boiling and roasting is essential to utilize an induction range.

 

A new user may find it difficult to get a starting point, but in my opinion the best way in is "The Little SAS Bok, a primer". It is now in 5. edition and not so little anymore, but it takes you in hand and guides you all the way from a having a basic understanding to become a full fledged SAS programmer. This link gives an introduction to the book:
https://www.sas.com/storefront/aux/en/splsb/65423_excerpt.pdf

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 17 replies
  • 1760 views
  • 4 likes
  • 7 in conversation