BookmarkSubscribeRSS Feed
nickb
Calcite | Level 5
I'm using a data step to build up multiple ftp put statements and I need to remove all leading zeros. The person ID is the value with the leading zeros. I'm also trying to figure how to put the quit keyword after the last occurence. I thought last. would work but it isn't coming out correctly.

Below is the data step.

data _null_;
set work.display_data;
by person_id_nb;
file max_pics;


line1 = 'cd incoming';
line2 = 'put \\location\of\thepics' ||trim(person_id_nb) || '.jpg';
Line3 = 'quit';

if _N_ = 1 then put line1;
put line2;
if _N_ = lastobs then put line3;



run;
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Suggest checking the forum archives with SEARCH -- it's a popular topic. Also, you could use the END= keyword on the SET statement to detect the end-of-file condition.

Scott Barry
SBBWorks, Inc. Message was edited by: sbb
Robert_Bardos
Fluorite | Level 6
Nick,

try somewhat along these lines:


data ids ; id='00123' ; output ; id='04567' ; output ; stop ; run ;
data _null_ ;
set ids end=lastobs ;
if _n_ = 1 then put 'cd incoming' ;
idnum = input(id,best.) ;
put 'put \\your_location\' idnum +(-1) '.jpg' ;
if lastobs then put 'quit' ;
run ;

HTH
Robert Message was edited by: Robert.Bardos
nickb
Calcite | Level 5
That works great but what if the id's are coming from a temporary data set?
nickb
Calcite | Level 5
I got it to work. Thanks again for the help.

Nick

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1524 views
  • 0 likes
  • 3 in conversation