BookmarkSubscribeRSS Feed
Tessy
Calcite | Level 5

I am using sas studio in the SAS OnDemand for academics, 

I imported cvs file to sas table

I want to produce 2 new tables for men and woman, but when I use the following code I get no observations in the mens output table and the original data set in the females output table 

 

This is the code I used:

 

/* Código generado (IMPORT) */
/* Archivo de origen: tsdem.csv */
/* Ruta de origen: /home/tessygsv0/ECOPRED CSV */
/* Código generado el: 29/1/19 15:17 */

%web_drop_table(WORK.TSDEM);


FILENAME REFFILE '/home/tessygsv0/ECOPRED CSV/tsdem.csv';

PROC IMPORT DATAFILE=REFFILE
DBMS=CSV
OUT=WORK.TSDEM;
GETNAMES=YES;
RUN;

PROC CONTENTS DATA=WORK.TSDEM; RUN;


%web_open_table(WORK.TSDEM);

 

This the code which is not working:

 

data hombres mujeres;
set work.TSDEM;
if SEXO='1' then output hombres;
else output mujeres;
run;

5 REPLIES 5
ErikLund_Jensen
Rhodochrosite | Level 12

Hi Tessy

 

Your if-then-else-construct writes to the mujeres-dataset, if variable SEXO is empty or anything but '1' . Are you sure that your import works as expected, so you actually get value '1' for hombres? - Try making a Proc print and see what you get.

Tessy
Calcite | Level 5
Thank you for your help.

I did the procprint procedure, I didn't get any value as result, but I got
this LOG

CODE:

proc print data=WORK.tsdem;
%let obsKeep = 10;
var LLAVE_J SEXO EDAD;
run;

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
4 OPTIONS LOCALE=es_419 DFLANG=LOCALE;
______
14
ERROR 14-12: Invalid option value ES_419 for SAS option LOCALE.
70
71 proc print data=WORK.tsdem;
72 %let obsKeep = 10;
73 var LLAVE_J SEXO EDAD;
74 run;
NOTE: There were 309863 observations read from the data set WORK.TSDEM.
NOTE: PROCEDIMIENTO PRINT used (Total process time):
real time 17.12 seconds
user cpu time 17.10 seconds
system cpu time 0.03 seconds
memory 4167.62k
OS Memory 35760.00k
Timestamp 30/01/2019 05:14:35 p.m.
Step Count 112 Switch Count 1
Page Faults 0
Page Reclaims 413
Page Swaps 0
Voluntary Context Switches 11
Involuntary Context Switches 21
Block Input Operations 0
Block Output Operations 8720

Tom
Super User Tom
Super User

That error has nothing to do with your code.

SAS is complaining about the setting for the LOCALE option.

 

4 OPTIONS LOCALE=es_419 DFLANG=LOCALE;
                 ______
                 14
ERROR 14-12: Invalid option value ES_419 for SAS option LOCALE.

Check and see if there is an option or preference setting in SAS/Studio that will let you change that so that SAS/Studio doesn't try to send SAS and invalid value.

Reeza
Super User

In general you rarely need to split your data set, instead use By statements. See the sample below. If you want to get your code working, please post the log from your code. 

 

proc sort data=tsdem;
by sexo;
run;

proc freq data=tsdem;
table sexo;
run;

proc print data=tsdem;
by sexo;
run;


proc means data=TSDEM;
by sexo;
run;

@Tessy wrote:

I am using sas studio in the SAS OnDemand for academics, 

I imported cvs file to sas table

I want to produce 2 new tables for men and woman, but when I use the following code I get no observations in the mens output table and the original data set in the females output table 

 

This is the code I used:

 

/* Código generado (IMPORT) */
/* Archivo de origen: tsdem.csv */
/* Ruta de origen: /home/tessygsv0/ECOPRED CSV */
/* Código generado el: 29/1/19 15:17 */

%web_drop_table(WORK.TSDEM);


FILENAME REFFILE '/home/tessygsv0/ECOPRED CSV/tsdem.csv';

PROC IMPORT DATAFILE=REFFILE
DBMS=CSV
OUT=WORK.TSDEM;
GETNAMES=YES;
RUN;

PROC CONTENTS DATA=WORK.TSDEM; RUN;


%web_open_table(WORK.TSDEM);

 

This the code which is not working:

 

data hombres mujeres;
set work.TSDEM;
if SEXO='1' then output hombres;
else output mujeres;
run;


 

ballardw
Super User

Doesn't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 1764 views
  • 0 likes
  • 5 in conversation