BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Fancy
Calcite | Level 5

Hello Everyone,

 

I cannot seem to get my code to generate the data in the EarningRangesLow variable beyond $1. Any help is appreciated. Here is my code:

 

data Chesapeake4 ;
infile '/home/sherstewart0/my_content/Chesapeake4.csv' dsd firstobs=3 delimiter=',';
length EarningRangesLow $ 100 EarningRangesHigh $ 100;
format MaleWorkedFT best32.;
format FemaleWorkedFT best32.;

do EarningRangesLow ="$1 "
,"$2,500 "
,"$5,000"
,"$7,500"
,"$10,000 "
,"$12,500 "
,"$15,000 "
,"$17,500"
,"$20,000 "
,"$22,500 "
,"$25,000 "
,"$30,000"
,"$35,000"
,"$40,000"
,"$45,000 "
,"$50,000 "
,"$55,000"
,"$65,000 "
,"$75,000"
,"$100,000 ";


do EarningRangesHigh="$2,499 "
,"$4,999 "
,"$7,4999"
,"$9,999"
,"$12,499"
,"$14,999 "
,"$17,499 "
,"$19,999"
,"$22,499 "
,"$24,999"
,"$29,999 "
,"$34,999"
,"$39,999"
,"$44,999"
,"$49,999 "
,"$54,999"
,"$64,999"
,"$74,999"
,"$99,999"
,"$149,999 "
;

input skip $ MaleWorkedFT FemaleWorkedFT ;
drop skip;

output;

end;
end;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

You seem to need something like this:

data Chesapeake4;
array a(20) $10 _temporary_ (
"$1 "
,"$2,500 "
,"$5,000"
,"$7,500"
,"$10,000 "
,"$12,500 "
,"$15,000 "
,"$17,500"
,"$20,000 "
,"$22,500 "
,"$25,000 "
,"$30,000"
,"$35,000"
,"$40,000"
,"$45,000 "
,"$50,000 "
,"$55,000"
,"$65,000 "
,"$75,000"
,"$100,000");
array b(20) $10 _temporary_ (
"$2,499 "
,"$4,999 "
,"$7,4999"
,"$9,999"
,"$12,499"
,"$14,999 "
,"$17,499 "
,"$19,999"
,"$22,499 "
,"$24,999"
,"$29,999 "
,"$34,999"
,"$39,999"
,"$44,999"
,"$49,999 "
,"$54,999"
,"$64,999"
,"$74,999"
,"$99,999"
,"$149,999");
infile '/home/sherstewart0/my_content/Chesapeake4.csv' dsd firstobs=3 delimiter=',';
do i = 1 to dim(a);
    EarningRangesLow = a{i};
    EarningRangesHigh = b{i};
    input skip $ MaleWorkedFT FemaleWorkedFT ;
    output;
    end; 
drop i skip;
run;
PG

View solution in original post

5 REPLIES 5
novinosrin
Tourmaline | Level 20

Is it just for fun: You can play with something like this

 

 

 data want;

 do _EarningRangesLow=1 to 100000 by 2500;

 EarningRangesLow=put(_EarningRangesLow,dollar10. -l);

 if _EarningRangesLow=1 then  _EarningRangesHigh=2499;

 else _EarningRangesHigh=_EarningRangesHigh+2500;

 EarningRangesHigh=put(_EarningRangesHigh,dollar10. -l);

  output;

 if _EarningRangesLow=1 then _EarningRangesLow=0;

end;

drop _:;

run;

 

Fancy
Calcite | Level 5

Thanks, I will try playing with that. So many different ways to approach this. It can be frustrating... 

ballardw
Super User

How many records are in your CSV file? If it is fewer than 20 you run out of lines to input while still in the first loop for the EarningRangesLow.

 

Are attempting generate someth that is supposed to create something like:

 

MaleworkedFt FemaleWorkedFt       1 2499

MaleworkedFt FemaleWorkedFt 2500 4999

 

I suspect that FORMATS will do what you want but you'd have to describe what this data is going to be used for.

PGStats
Opal | Level 21

You seem to need something like this:

data Chesapeake4;
array a(20) $10 _temporary_ (
"$1 "
,"$2,500 "
,"$5,000"
,"$7,500"
,"$10,000 "
,"$12,500 "
,"$15,000 "
,"$17,500"
,"$20,000 "
,"$22,500 "
,"$25,000 "
,"$30,000"
,"$35,000"
,"$40,000"
,"$45,000 "
,"$50,000 "
,"$55,000"
,"$65,000 "
,"$75,000"
,"$100,000");
array b(20) $10 _temporary_ (
"$2,499 "
,"$4,999 "
,"$7,4999"
,"$9,999"
,"$12,499"
,"$14,999 "
,"$17,499 "
,"$19,999"
,"$22,499 "
,"$24,999"
,"$29,999 "
,"$34,999"
,"$39,999"
,"$44,999"
,"$49,999 "
,"$54,999"
,"$64,999"
,"$74,999"
,"$99,999"
,"$149,999");
infile '/home/sherstewart0/my_content/Chesapeake4.csv' dsd firstobs=3 delimiter=',';
do i = 1 to dim(a);
    EarningRangesLow = a{i};
    EarningRangesHigh = b{i};
    input skip $ MaleWorkedFT FemaleWorkedFT ;
    output;
    end; 
drop i skip;
run;
PG
Fancy
Calcite | Level 5

Thanks that worked like a charm...! 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 841 views
  • 0 likes
  • 4 in conversation