data Porto; input apple lemon orange; datalines; 1 2 3 2 3 4 3 4 5 1 5 5 3 0 0 6 0 0 7 0 0 run; PROC SQL; create table result as SELECT DISTINCT count(*) into :total FROM Porto; QUIT; proc print data=result; run;
if I skip the line "create table result as" Is the code not gonna to save any output? is it just gonna showing in the log whatever is identified?
what does count(*) into :total means? is it just total number of rows in table Porto? what is :total? this is looking very strange I tried the code and the output is very strange too...
SELECT INTO is the method to create macro variables from SQL. So your step creates macro variable &total which holds the count of all observations in the dataset porto.
The DISTINCT in your query serves no purpose (there is only one count anyway), so remove it. Without a CREATE TABLE, only the macro variable and the print output are created. When the sole purpose of the step is to create the macro variable, run PROC SQL with the NOPRINT option.
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.