BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8
PROC SQL noprint;
SELECT DISTINCT
count(*) into :total_Dev
FROM &POrt._dev;
QUIT;

what does count(*) into :total_Dev means?

8 REPLIES 8
HeatherNewton
Quartz | Level 8

also is the output data set same as the source data set &Port._dev? here didnt start with data and dataset name so where are the data saved? 

japelin
Rhodochrosite | Level 12

There is no output dataset because there is no "create table". Only results are available.
It is necessary that learning basic sql syntax before using proc sql.

 

ballardw
Super User

INTO : , that colon is extremely important, means the results get placed into one or more macro variables whose names follow the colon depending on actual syntax.

 

Suggestion: From the level of understanding you show with your questions you should not be working with macro variables or code at all yet. The SAS macro language is used to create code elements. If you do not know our understand those elements use of the macro language will cause problems, confusion and very likely data corruption and/or unstable SAS sessions.

 

Macro language will involve lots of % functions and statements and macro variable names that start with &.

Kurt_Bremser
Super User

The SQL summary function counts the number of non-missing values in its argument. * denotes all columns/variables in the dataset, so you get a count of all observations where at least one column is not missing.

FreelanceReinh
Jade | Level 19

Minor correction: COUNT(variable) returns the number of observations with non-missing values of variable, but COUNT(*) returns the number of observations regardless of missing values.

Sajid01
Meteorite | Level 14

Hello @HeatherNewton 
"what does count(*) into :total_Dev means "
It means create a macro variable total_Dev that has the total number of rows in the table or dataset.

As you are using Select distinct, the macro variable total_Dev will have the count of distinct observations in the table.

FreelanceReinh
Jade | Level 19

It's DISTINCT count(*) -- not count(distinct sql-expression). Since count(*) returns a single number in this case (as there is no GROUP BY clause), the DISTINCT keyword is redundant. The TRIMMED  keyword (... into :total_Dev trimmed) would make more sense to avoid leading blanks in macro variable total_Dev.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 8 replies
  • 2729 views
  • 3 likes
  • 6 in conversation