data ds;
input item_name: $ 15. total_count;
datalines;
Water_Bottle 2
Tent 1
Apple 4
;
run;
data split;
set ds;
do split=1 to total_count;
output;
end; drop total_count;
proc print ;
run;
Q)1. How to get split item count using proc sql
proc sql;
create table spliSQL as
select * from split
;
quit;
😜
... and seriously, sql is not a tool for such job (Maxim 14), data step is.
Bart
Not possible with standard SQL as implemented in SAS.
Most databases have extensions like T-SQL or PL-SQL that allow for loops. In SAS you've got the data step for this.
Simple (and correct) answer: Don't.
SQL is not the tool for such a task, the DATA step is. Maxim 14 (as already mentioned).
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.