BookmarkSubscribeRSS Feed
pavank
Obsidian | Level 7
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
3 REPLIES 3
yabwon
Onyx | Level 15
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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Patrick
Opal | Level 21

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 326 views
  • 1 like
  • 4 in conversation