Hello team,
I have this:
proc sql; select counts (*) into: avariableName from mytable; quit;
Respectfully,
blue & blue
Search on the web for URL that contain the three words "sas sql into".
The first link the appeared for my search was
SAS(R) 9.3 SQL Procedure User's Guide
Actually I suspect it does nothing except throw an error because there is no function COUNTS.
Using a data set I know exists:
109 proc sql; 110 select counts (*) into: avariableName 111 from sashelp.class; ERROR: * used for a function other than COUNT. ERROR: Function COUNTS could not be located. 112 quit;
Using the function Count, that does exist:
113 proc sql; 114 select count (*) into: avariableName 115 from sashelp.class; 116 quit; NOTE: PROCEDURE SQL used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 117 118 %put The macro variable Avariablename=&avariablename.; The macro variable Avariablename= 19
@GN0001 wrote:
Hello team,
I have this:
proc sql; select counts (*) into: avariableName from mytable; quit;Respectfully,
blue & blue
Count(*) basically counts observations
Using COUNT(*) causes SQL to read the whole dataset; it is much better (faster) to query the dataset metadata:
proc sql noprint;
select nobs (*) into: avariableName
from dictionary.tables
where libname = "WORK" and memname = "MYTABLE";
quit;
What part don't you understand?
PROC SQL?
SELECT?
COUNT() function?
COUNT(*)?
INTO?
:?
FROM?
What do you think it does from the context of the program where it was used?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.