Help using Base SAS procedures

stripping leading zeros

Reply
Contributor
Posts: 65

stripping leading zeros

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;
Super Contributor
Super Contributor
Posts: 3,174

Re: stripping leading zeros

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
Frequent Contributor
Posts: 106

Re: stripping leading zeros

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
Contributor
Posts: 65

Re: stripping leading zeros

Posted in reply to Robert_Bardos
That works great but what if the id's are coming from a temporary data set?
Contributor
Posts: 65

Re: stripping leading zeros

Posted in reply to Robert_Bardos
I got it to work. Thanks again for the help.

Nick
Ask a Question
Discussion stats
  • 4 replies
  • 196 views
  • 0 likes
  • 3 in conversation