PROC SQL noprint; SELECT DISTINCT count(*) into :total_Dev FROM &POrt._dev; QUIT;
what does count(*) into :total_Dev means?
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?
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.
Look up the document and read it.
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n1tupenuhmu1j0n19d3curl9igt4.htm
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 &.
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.
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.
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.
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.
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!
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.
Ready to level-up your skills? Choose your own adventure.